我该如何将一个
元素放置在页面底部,即使我滚动页面它也会保持在那里?这可以只使用CSS完成,还是需要同时使用jQuery?DEMO
div.footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
height: 100px;
/* etc. */
}
在你的“页脚”div
上使用position: fixed
,并在body
中添加padding-bottom: 50px
(与你的“页脚”div
相同的高度),这样当你滚动到底部时,不会隐藏任何内容:
参见:http://jsfiddle.net/gyExR/19/
body {
padding-bottom: 50px
}
div {
position: fixed;
..
}
浏览器支持: http://caniuse.com/css-fixed
position: fixed
不受 IE 6 或许多移动浏览器(包括 Mobile Safari)的支持。 - eyelidlessness