If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3

Thread: Hello, All

  1. #1
    Join Date
    May 2011
    Member #
    3 times
    Martin Rinehart here. Currently hard at work on a JavaScript OOP book and wishing I didn't keep running into CSS roadblocks. Anyone got a "how do I vertically center a div?" answer that isn't a total kludge?



  3. #2
    WDF Staff AlphaMare's Avatar
    Join Date
    Oct 2009
    Montreal, Canada
    Member #
    878 times
    This is one way that works - don't know if it qualifies as a kludge or not.
    Centers both vertically and horizontally - but it depends on your knowing the width and height of the div.

    #divname {
    height: div height (in pixels or ems)
    width: div width (in pixels or ems)
    margin-top: half your div height;
    margin-left: half your div width;
    (any other css properties can go here)
    TheGAME1264 likes this.
    Good design should never say "Look at me!"
    It should say "Look at this." ~ David Craib ~ my current site . . ~ my email

    If you feel that someone's post helped you fix your problem, answered your question, or just made you feel better, feel free to "Like" their post. The "Like" link is at the bottom right of each post, along side the "reply" link. And if you are being helped here, try to help someone else - pass it on!

  4. #3
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Not from USA
    Member #
    2784 times
    The truth is there is no vertical centering of a div that isn't a mess. It was an element for which vertical centering wasn't originally intended.

    With that said, the Mare gave you your answer.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
All times are GMT -6. The time now is 09:53 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2020 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: