javascript - 强制 div 到达底部

标签 javascript jquery html css footer

我在SO中浏览了同样的问题,但没有一个能很好地工作[跨浏览器兼容]。
所以,我正在寻找同样的工作来用 jQuery 来解决。
我想将 div 放置在 HTML 页面的底部,而不是屏幕的底部。

到目前为止我只尝试过 CSS

clear: both;

min-height: 6%;

position: fixed;

bottom: 0;

编辑
我的CSS

html, body {

margin: 0px;

padding: 0px;

height: 100%;

}

#footer {

 width: 100%;

 height: 6%;

 position: absolute;

 bottom:0px;
 left:0px;
}

#content {

float: left;

width: 59.5%;

height: 83%;

position:relative;

}

#news {
 z-index:2;
}

<html>
 <div id="content">
  <div id="news"> </div>
 </div>
 <div id="footer"></div>
<html>

最佳答案

我相信您毕竟想要粘性页脚。

jsfiddle demo

它使用 this sticky footer .

基本想法是使用粘性页脚或基本上任何粘性页脚,然后为您的#wrap着色,因为它将垂直覆盖整个视口(viewport)

关于javascript - 强制 div 到达底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6743428/

相关文章:

javascript - 从 AngularJS $http get 返回对象

javascript - Select2 - 多个标签不起作用

javascript - 我怎样才能使文本区域内容中的外观值取决于所选值

使用单例模式的 JavaScript 函数链

javascript - MVC 的 JQuery.JqGrid 插件可以在 Nuget 中免费使用吗

javascript - 从输入值中删除单击的 id

javascript - 缩放 div 以适合窗口但保持纵横比

javascript - 压缩相似的函数

html - 将可调整大小的弹出框定位到屏幕中心,而不使用百分比宽度

javascript - jQuery - 在页面上显示下一个元素并在单击时隐藏当前元素的函数