如何将文字粘贴到页面底部?

Mis*_*hko 20 html css

我想在页面底部添加一行"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)


Ser*_*sky 23

尝试:

.bottom {
    position: fixed;
    bottom: 0;
}
Run Code Online (Sandbox Code Playgroud)


Tho*_*eld 9

试试这个

 <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)

  • 我对其进行了编辑以使其发挥作用,并将使其保持在中心位置,因为我也需要它。希望其他人也会发现它很有用。 (2认同)

Cho*_*gun 5

从我的研究和这篇文章开始,我认为这是最好的选择:

<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)

此选项允许调整页面大小,即使页面是空白的,它也会留在底部。