css - 中心列设置为 100% 高度的粘性页脚

标签 css

我的粘性页脚可以正常工作,但我希望我的测试容器能够从浏览器顶部到达页脚。我怎样才能做到这一点?除了中心列的高度外,它都在工作。

HTML:

<div id="wrap">
  <!--All of your content goes here-->
  <div id="test">test</div>
  <div class="push"></div>
</div>
<div class="pagefooter">footer</div>

CSS:

html, body { width:100%; height:100%; }
#wrap { 
min-height:100%;
height:auto !important;
height:100%;    
margin: 0 auto -158px;  /* Bottom value must = footer height */
}

.pagefooter, .push { width:100%; height:158px; position:relative; bottom:0; }


#test{
    background-color: red;
    height:100%;  
}

最佳答案

试试这个:

#wrap{width:100%;display:table;}
#test{display:table-row;}

并删除 .push div。

Fiddle here.

关于css - 中心列设置为 100% 高度的粘性页脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20140300/

相关文章:

html - Bootstrap : move navbar under the logo bar

javascript - 使用 $().html 时 mdui 的一些效果消失了

jquery - 我如何使用不同的颜色?

html - 剪掉图像的中间部分(示例所示)?

java - CSS 文件未加载?

css - 如何修复 `<span>` 元素中溢出的字形?

Javascript |网页 |饼图状态

html - 我怎么知道为什么忽略 CSS 样式?

javascript - 具有动态内容的 Flexbox 响应式 super 菜单

html - 使 HTML 水平列表不易损坏