html - CSS3 + HTML5 中的粘性页脚

标签 html css sticky-footer

我正在学习 CSS3 和 HTML5,并且对粘性页脚的最佳实践感到好奇。我应该知道的任何 box/flex/cool 属性吗?

最佳答案

这对我有用,似乎是我找到的最简单的解决方案:

<style type="text/css">
   html,body {
      height:100%
   }

   #wrapper {
     min-height:100%;
     margin-bottom:-150px; /* negative total computed height of footer */
   }

   #footer_padding {
     height:150px; /* total computed height of footer */
   }

   #footer {
     height:100px;
     margin-top:50px;
   }
</style>    


<div id="wrapper">

   <div>some content...</div>

   <div id="footer_padding"></div>

</div>

<div id="footer"></div>

关于html - CSS3 + HTML5 中的粘性页脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14591609/

相关文章:

jquery - 处理程序没有收到事件

javascript - 选择 FromDate 和 ToDate 时启用提交按钮

html - 实现停靠页脚的最有效和兼容的方式

css - 修复了 960.gs 的页脚

html - 响应式菜单问题 - 单击时不打开

CSS:每行一个 DIV,在一个 DIV 内水平堆叠图像和文本,并应用边距

java - 如何使用 Java 计算 Selenium WebDriver 中的 HTML 子标签

css - body 和 child 身上带有 flexbox 的粘性页脚

html - 使内容在嵌套的 flex 容器内水平滚动并具有位置粘性

javascript - 通过纯 JavaScript Ajax 调用获取 HTML 响应但未执行