这是我的问题,我使用的布局具有粘性页脚(使用 cssstickyfooter.com 方法)。在我的容器 div 中,我有一个内容 div,其中包含其他四个 div。像这样:
<div class="container">
<div class="content">
<div id="1"></div>
<div id="2"></div>
<div id="3"></div>
<div id="4"></div>
</div>
</div>
<div class="footer"></div>
为了使粘性页脚正常工作,所有 div 都需要具有position:relative;
设置,因为 div 将包含不同长度的内容,并且需要相应地重新调整大小。然而我的困境开始是我需要让 div 1-4 有position:absolute;
设置,以便它们将堆叠在具有相同 (x,y) 位置的彼此之上。
有什么办法可以实现我所需要的吗?
我建议瑞恩·法伊特 https://web.archive.org/web/20161118224005/http://ryanfait.com/resources/footer-stick-to-bottom-of-page/的粘页脚,效果很好!
* {
margin: 0;
}
html,
body {
height: 100%;
}
.wrapper {
min-height: 100%;
height: auto !important;
/* This line and the next line are not necessary unless you need IE6 support */
height: 100%;
margin: 0 auto -20px;
/* the bottom margin is the negative value of the footer's height */
}
.footer,
.push {
height: 20px;
/* .push must be the same height as .footer */
}
<body>
<div class="wrapper">
<p>Your website content here.</p>
<div class="push"></div>
</div>
<div class="footer">
<p>Copyright (c) 2008</p>
</div>
</body>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)