我想在页面底部添加一行"All Rights Reserved ...".我尝试使用绝对定位,但当窗口调整到较小的高度时,这不能按预期工作.
我怎样才能实现这个简单的目标?
Kon*_*rak 25
您可能希望将绝对对齐的div放在相对对齐的容器中 - 这样它仍将包含在容器中而不是浏览器窗口中.
<div style="position: relative;background-color: blue; width: 600px; height: 800px;">
<div style="position: absolute; bottom: 5px; background-color: green">
TEST (C) 2010
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
试试这个
<head>
<style type ="text/css" >
.footer{
position: fixed;
text-align: center;
bottom: 0px;
width: 100%;
}
</style>
</head>
<body>
<div class="footer">All Rights Reserved</div>
</body>
Run Code Online (Sandbox Code Playgroud)
从我的研究和这篇文章开始,我认为这是最好的选择:
<p style=" position: absolute; bottom: 0; left: 0; width: 100%; text-align: center;">This will stick at the botton no matter what :).</p>
Run Code Online (Sandbox Code Playgroud)
此选项允许调整页面大小,即使页面是空白的,它也会留在底部。