Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



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

Posts: 548
Name: Danny Angelosanto
Trades: 0
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
__________________
"The only reason some people get lost in thought is because it's unfamiliar territory."
_____________________________________
Angelosanto is offline
Reply With Quote
View Public Profile Visit Angelosanto's homepage!
 
 
Register now for full access!
Old 08-01-2007, 09:00 PM Re: How to center a div/web page
DrSeuss's Avatar
Skilled Talker

Posts: 60
Name: Matt
Trades: 0
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, 09:40 PM Re: How to center a div/web page
LadynRed's Avatar
Defies a Status

Posts: 10,016
Location: Tennessee
Trades: 0
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 !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 08-01-2007, 10:27 PM Re: How to center a div/web page
Angelosanto's Avatar
Webmaster Talker

Posts: 548
Name: Danny Angelosanto
Trades: 0
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
__________________
"The only reason some people get lost in thought is because it's unfamiliar territory."
_____________________________________
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 Search this Thread
Search this Thread:

Advanced Search

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

BB 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.13611 seconds with 12 queries