当浏览器窗口高度减小时,我试图防止我的页脚重叠到它上面的元素上。我意识到这是因为另一个 divcontainer
没有继承内部 div 的高度,即#cart
.
如何让外部 div 继承内部非浮动 div 的高度?
这是它发生的页面:
http://fine-grain-2.myshopify.com/cart
请参阅下面的屏幕截图以获取说明:
我希望它是怎样的:
当前浏览器窗口高度太短时的情况。
HTML:
<div class="container">
<div id="cart" class="cart clearfix">
</div>
<footer class="clearfix">
<div class="additional-info"> Copyright © 2013 fine grain </div>
</footer>
CSS:
.container:after {
clear: both;
content: " ";
display: block;
height: 0;
visibility: hidden;
}
.container {
height: 100%;
margin: 0 auto;
padding: 0;
position: relative;
width: 960px;
}
.row:after, .clearfix:after {
clear: both;
}
.clearfix:before, .clearfix:after, .row:before, .row:after {
content: " ";
display: block;
height: 0;
overflow: hidden;
visibility: hidden;
width: 0;
}
.clearfix:before, .clearfix:after, .row:before, .row:after {
content: " ";
display: block;
height: 0;
overflow: hidden;
visibility: hidden;
width: 0;
}
#cart {
margin: 20px auto 0;
}
footer {
clear: both;
margin: 0 auto;
padding: 0 0 1em;
position: relative;
text-align: center;
}
.additional-info {
font-size: 0.8em;
}