How would I position a div so that its horizontical(left-right) center would be the center of the page(the center of body)? Can I somehow set it's handle to it's own center and just use: left:50%; ?
Printable View
How would I position a div so that its horizontical(left-right) center would be the center of the page(the center of body)? Can I somehow set it's handle to it's own center and just use: left:50%; ?
There are two ways, and you need a fixed width for both. For in-flow boxes, you use margins.
For out-of-flow boxes, you use, uh, margins :)Code:#thediv {
width: 100px;
margin-left: auto;
margin-right: auto;
}
Code:#thediv {
position: absolute;
width: 100px;
margin-left: -50px; /* Half the negative width. */
left: 50%;
}
Ah, nice :) - thanks!