Reply
How to center a div/web page
Old 08-01-2007, 07:38 PM How to center a div/web page
Angelosanto's Avatar
Ultra Talker

Posts: 424
Name: Danny Angelosanto
Hey guys, I get asked this question a lot, and as I got asked it today, I decided to write a post about it.

So for all who are interested, here it is

Hope that helps
Angelosanto is offline
Reply With Quote
View Public Profile Visit Angelosanto's homepage!
 
When You Register, These Ads Go Away!
     
Old 08-01-2007, 08:00 PM Re: How to center a div/web page
DrSeuss's Avatar
Skilled Talker

Posts: 60
Name: Matt
I have to admit, I'm new to this, but wouldn't it be easier to do it like this?

body {
text-align: center;
}

#container {
width: whatever width you want;
margin: auto auto;
}

This seems to be working on my site...

What I would like to know is if there is a way to center the #container vertically... so if i have a page that has a set height, and it is viewed an a higher resolution, it will appear in the center of the viewable window with even margins top bottom and left right. Is it possible?
DrSeuss is offline
Reply With Quote
View Public Profile
 
Old 08-01-2007, 08:40 PM Re: How to center a div/web page
LadynRed's Avatar
Super Moderator

Posts: 6,406
Location: Tennessee
Quote:
What I would like to know is if there is a way to center the #container vertically
There's no easy solution to that really. To do that to suit all resolutions you need at least some javascript. An easier method is a cheat, using a 'shiv' div to push it down vertically.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!
"Using or working with IE is like having to wear a 1970's polyester suit with pantyhose and a girdle, to work everyday"
Carolina Corvette Club
LadynRed is offline
Reply With Quote
View Public Profile
 
Old 08-01-2007, 09:27 PM Re: How to center a div/web page
Angelosanto's Avatar
Ultra Talker

Posts: 424
Name: Danny Angelosanto
Quote:
Originally Posted by DrSeuss View Post
.

What I would like to know is if there is a way to center the #container vertically... so if i have a page that has a set height, and it is viewed an a higher resolution, it will appear in the center of the viewable window with even margins top bottom and left right. Is it possible?
Surely thats a fairly rare problem though? I've never designed a website thats basically just a box, and I hardly ever come across them whilst browsing
Angelosanto is offline
Reply With Quote
View Public Profile Visit Angelosanto's homepage!
 
Reply     « Reply to How to center a div/web page
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13744 seconds with 13 queries