Log in

View Full Version : Center content, vertically and horizontally?



ian_6500
01-23-2010, 06:12 AM
I'm looking for some script or some way of centering my content in the browser window both horizontally and vertically. I found one script which works, but the pages jump from the corner to the center each time they're loaded which is jarring to look at. Any thoughts? Thanks!

graigkarl
01-23-2010, 04:05 PM
I usually fix this by using the <center> tag and having the rest of my website in a 'div wrapper'. like this:

<body>
<center>
<div style="text-align: left;">

the code for my site goes here

</div>
</center>
</body>

hopefully this help you

graigkarl
01-23-2010, 04:07 PM
the div SHOULD be given the same width as your page for best results

ian_6500
01-23-2010, 04:13 PM
Thanks! But do you know how to center vertically as well?

molendijk
01-23-2010, 04:19 PM
See this thread (http://www.dynamicdrive.com/forums/showthread.php?t=51817).
===
Arie Molendijk.

ian_6500
01-23-2010, 05:11 PM
Success! That did the trick. You have no idea how long it's taken me to find a solution to what seems like such a basic thing. Thanks!:)