How to make a DIV layer centered!
It is a challenge among many CSS designers to get the CSS page works same as they expected in all and every browsers. Different browsers render some of the CSS tags in different ways and some are omitted completely. No one will forget the IE 6 as a big headache and a bug full browser ever. It’s behavior torches all CSS designers. Thanks Microsoft they upgraded themselves with IE7.
Centering a layer is not that much harder part. It is simple but it is the start of most web page. So it is worth knowing the right syntex that works with almost all browsers today. Following is a sample style that works in all browsers.
CSS Style
1 2 3 4 5 6 7 8 9 10 11 12 | body { margin: 0px; padding: 0px; text-align:center; } #outerWrapper { width:900px; margin:0 auto; border:1px #999 solid; } |
The Body
1 | <div id="outerWrapper"></div> |
Cool ! It is working fine. By the way, I have a absolute positioned layer. Will this work with this idea.
No problem buddy. There is nother technique using the negative margin.
1 2 3 4 5 6 | #outerWrapper{ position: absolute; left: 50%; width: 900px; margin-left: -450px; } |
Check wheather is this work for you. Probably it should.




