This example shows how to set a fixed width box centered both vertically and horizontally with just CSS.It works simply by using absolute positioning of 50% and then using negative margins 1/2 the width and height of the object to compensate. Tested in IE 6, 7, FF, Safari etc.. This can also be done with percentages but that method however takes a bit more lovin to get it to behave in IE.
Working Example
#container {
width:400px;
height:200px;
position:absolute;
top:50%;
left:50%;
margin:-100px 0 0 -200px;
border:solid 1px #CCCCCC;
padding:8px;
overflow:auto;
}
Yup! Its that easy!
This post has been edited by moojoo: 01 December 2006 - 11:39 AM


Help


MultiQuote















