Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 952809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:57:12+00:00 2026-05-15T23:57:12+00:00

I would like an elements top margin to be specified as a percentage of

  • 0

I would like an elements top margin to be specified as a percentage of the height of the window, is this possible?

If i set something to have a css property like the below

#idName{margin:10% 0;}

this will set it to 10% of the width of the browser viewport, which is not the desired behaviour.

The reason i want to do this is my site has content in say a 500px high box which i want to be in the center of the browsers viewport. So say the viewport is 500px high, it will have a margin-top or 0px, but if 600px high it will have margin-top of 50px, 700px high margin-top of 100px etc.

Please tell me the best way to achieve this!

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T23:57:13+00:00Added an answer on May 15, 2026 at 11:57 pm

    Vertical alignment can be tricky in css.

    These articles give a pretty good overview of techniques to achieve it:

    http://hicksdesign.co.uk/journal/how-to-vertical-centering-with-css

    http://www.vdotmedia.com/blog/vertically-center-content-with-css/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a set of checkboxes I would like to position using CSS. This
I have a space in which I would like certain elements (represented here by
I would like to select all elements that have certain attribute or don't have
I would like to select a set of elements that are both of a
I would like to add a randomly generated margin-left and margin-top values to each
I would like to filter NSMutableArray elements that contains some string. ListArchives is filled
I would like to cycle through four li elements that all contain tags, setting
I would like to implement some live elements to an existing PHP app. So
I would like to know how to read elements from a const boost::multi_array object.
I would like to select a subset of elements from a whole that satisfy

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.