...

View Full Version : CSS Positioning Help



Milan5baros
05-12-2011, 03:04 PM
I'm wondering how to position my website in the middle of someone's browser, in other words there's white space at either side and the website runs down the middle of the page even if someone resize's their browser or has a different size screen.

Also could someone explain containers too me?

Any help, tips appreciated :D

CHEWX
05-12-2011, 03:10 PM
margin: 0 auto;

On main div.

Search button is your friend :)

Milan5baros
05-12-2011, 03:12 PM
margin: 0 auto;

On main div.

Search button is your friend :)

Cheers man. Sorry to ask basic questions. I didn't really know what to search lol.

What do you mean on main div? I haven't yet created any in my CSS, apart from styling my body.

teedoff
05-12-2011, 03:23 PM
A common and masic practice would be to wrap everything thats inside your <body></body> tags in a div with an id or class of "wrapper" or "container".

Then in your stylesheet, you would target that id or class...id would be:


#wrapper {
width 960px;
margin: 0 auto;
}I give wrapper a width LESS that its containing element, which in this case is the <body>, then I set its top and bottom margins to 0 and its left and right margins to auto. Now just make sure you have a valid doctype and thats all you need to center an element.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum