我怎樣才能使內部的div延伸到容器大小的100%?請考慮下面的示例,我想要.footer是實際.wrapper大小的100%(500px,因爲.content內部元素的寬度爲500px)。
<html>
<head>
<style type='text/css'>
.wrapper {
width: 300px;
text-align: center;
overflow: auto;
}
.content {
width: 500px;
background-color: green;
}
.footer {
background-color: grey;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="content">PAGE CONTENT</div>
<div class="footer">FOOTER (should be 100%)</div>
</div>
</body>
</html>
如果你看一看http://jsfiddle.net/6at8Q/然後向右滾動,你會看到灰色條不會延長。
另外... http://stackoverflow.com/questions/6314993/div-fill-parent-container – JohnFx
divs默認是他們父母的寬度的100%。 – GolezTrol
另外... http://stackoverflow.com/questions/7675107/make-a-div-fill-the-whole-page-in-height – JohnFx