Click to See Complete Forum and Search --> : Centre Div


Dysan
01-31-2008, 03:55 PM
Hi, how do I display a centred div, that keeps the margins in tact, similar to the page found at "yell.com"

rulian
01-31-2008, 04:50 PM
one of div's and css's main drawback, the lack of "center"
you can set your left and top to 50% on the div, and then your left and top margins to offset half the div's height and width

Dysan
01-31-2008, 05:10 PM
How does Yell.com do it?

rulian
01-31-2008, 05:20 PM
they set body widht and height to 100
and then text-aligning things center, and verticle align middle
take a look at their css
http://www.yell.com/css/yell_home_001.css

Dysan
01-31-2008, 07:18 PM
What is their bear-essential code, that displays the centered white box, that everything sits on?

Weedpacket
01-31-2008, 08:21 PM
I wasn't even looking, and I found
http://aplus.co.yu/lab/rdc/

NogDog
02-01-2008, 06:51 PM
one of div's and css's main drawback, the lack of "center"
you can set your left and top to 50% on the div, and then your left and top margins to offset half the div's height and width
CSS:

#example {
width: 750px;
margin: 0 auto;
}

HTML

<div id="example">
<!-- page contents here -->
</div>