Here is how I solve it:
http://jsfiddle.net/WPuhU/1/
Also take care of the scroll bars (they don't appear if your window view is smaller than the crowded div). Auto centers overflow div.
CSS
#center-3 {height:40px;background-color: #999;}
#center-1 {height:20px;top:10px;background-color: #aaa;}
body {width:100%;margin:0;}
#center-4 {
width: 100%;
overflow:hidden;
position: absolute;
z-index: -1;
}
#center-3 {
position: relative;
margin: 0 auto;
width: 200px;
}
#center-2, #center-1 {
position: relative;
width: 400px;
}
#center-2 {
left: 50%;
}
#center-1 {
left: -50%;
}
HTML:
<div id="center-4">
<div id="center-3">
<div id="center-2">
<div id="center-1"></div>
</div>
</div>
</div>
<div id="other-stuff">Here comes the other stuff above.</div>
Alqin source
share