【发布时间】:2012-07-29 16:25:21
【问题描述】:
我正在尝试为响应式网站创建一个粘性页脚。我在互联网上搜索并找到了各种解决方案,但我的问题是由于页脚中的文本数量,页脚的高度变化是自动换行的。我已经尝试在 Ryan Fait 的网站 (http://ryanfait.com/resources/footer-stick-to-bottom-of-page/) 上使用该方法,但由于您无法将页脚的高度视为静态值,因此很难为 CSS 设置推送值。目前我只是将页脚固定在底部,但这会导致问题,因为随着页脚高度的增加,它会占用较小视口上的宝贵空间。下面是我的页脚中有多少信息的示例。有什么建议吗?
<footer>
<div id="upperFooter">
<p>2000 - 2012 College Name | Copyright | Internet Privacy Policy | Disclaimer | Collection and Use of Social Security Numbers</p>
</div>
<!-- end upperFooter -->
<div id="lowerFooter">
<p>College Name is a member of the Stated State College System. College Name is not affiliated with any other public or private university or College in State or elsewhere. </p>
<p>College Name is a division of College Name and is accredited by the Commission on Colleges of the Association of Colleges (“XIXI”) to award the baccalaureate and associate degree. Contact the Commission on Colleges at for questions about the accreditation of College Name.</p>
</div>
<!-- end lowerFooter -->
</footer>
【问题讨论】:
-
也许可以使用媒体查询刮掉任何不必要的内容。在移动设备上显示内容时,您实际上应该只显示最相关的内容。另一种选择是为移动设备堆叠导航。使用媒体查询更改布局。
-
Kris 的想法是个好主意,就让页脚占用更少的空间而言。当文本已经很小,并且如果您希望它可用(显然您会这样做,如果您要麻烦使其响应式),那么取出一些元素似乎是要走的路。另一个想法是隐藏页脚(设置
bottom: -150px;或其他)并允许用户点击一次以查看版权信息。 -
见this example。使用@media 查询来修复您关心的每个屏幕分辨率的页脚高度等。
标签: html css responsive-design sticky-footer