我有一个被包含在几个宽度均为100%的其他div中的div。 我这样做是因为我有一个外部div,带有我想要围绕整个页面的轻微边框图像。
HTML:
<body>
<div class="container" >
<div style="padding-top:15px; height:100%;">
<div class="wrapper">
<div class="contentContainer">
test
</div>
</div>
</div>
</div>
</body>
CSS:
*{margin:0; padding:0;}
body { margin: 0 auto; color: #333333; }
html, body { color: #000000; margin:0; padding:0; height:100%; }
.wrapper {width:940px; margin-left:20px; margin-right:20px; background:#fff; overflow:hidden; margin:0 auto; height:100%;}
.container {min-height:100%; height: auto !important; height:100%; margin: 0 auto -30px; width:980px; background:URL(images/bg_sides.jpg) repeat-y #f4f4f4;}
.contentContainer {width:920px; margin:0 auto; height:100%; }
Fiddle: http://jsfiddle.net/hc3Xu/2/