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

  • Home
  • SEARCH
  • 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

Using Zend_Form, how would I create form elements like this: <input type=text name=element[1] value=
I have an element with an onclick method. I would like to activate that
I would like to print only the contents of a textarea element from a
I would like to get the absolute position of an element in relation to
I would like to find out, in JavaScript, which element currently has focus. I've
Is there a way to vertically stack selected td elments? I would like to
In the following snippet, using XmlReader, when I encounter an element. I would like
Would like to get a list of advantages and disadvantages of using Stored Procedures.
Would like to create a strong password in C++. Any suggestions? I assume it
I would like to test a string containing a path to a file for

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.