[英]How to merge bottom border to the bottom of the page
I am trying to merge the footer border to the bottom of the page.我正在尝试将页脚边框合并到页面底部。 I have no actual border just the background colour.
我没有实际的边框,只有背景颜色。 The results I want to achieve:
我想要达到的结果:
I have tried using padding bottom, border-bottom-style but it is still not merging.我尝试过使用填充底部,边框底部样式,但它仍然没有合并。
My code:我的代码:
footer { background-color: #dddddd; padding-bottom: 40px; }
<footer> <p id="footername">Example Text</p> <p>Example Text</p> <p>Example Text</p> </footer>
I basically want the bottom white line to go away so that the grey background will connect to bottom page as seen in the first picture我基本上想要 go 的底部白线,以便灰色背景将连接到底部页面,如第一张图片所示
Firstly, I recommend you to open Console tab in Dev Tools and check if it is a margin or padding and what causes this.首先,我建议您在开发工具中打开控制台选项卡并检查它是边距还是填充以及是什么原因造成的。 If it is a body margin then you can simply do
margin: 0
on body element or try doing *{margin:0; padding: 0; box-sizing: border-box}
如果它是正文边距,那么您可以简单地在正文元素上执行
margin: 0
或尝试执行*{margin:0; padding: 0; box-sizing: border-box}
*{margin:0; padding: 0; box-sizing: border-box}
*{margin:0; padding: 0; box-sizing: border-box}
. *{margin:0; padding: 0; box-sizing: border-box}
。
This is how you make your footer stick to the bottom of the page.这就是让页脚粘在页面底部的方法。 You will have to add
position:fixed
.您必须添加
position:fixed
。 Then adjust the bottom:0
to make sure it is at the bottom然后调整
bottom:0
,确保它在底部
footer { position: fixed; left: 0; bottom: 0; width: 100%; background-color: #dddddd; padding-bottom: 40px; }
<footer> <p id="footername">Example Text</p> <p>Example Text</p> <p>Example Text</p> </footer>
easy to go, just use position: absolute;
易于 go,只需使用
position: absolute;
and set bottom: 0;
并设置
bottom: 0;
footer { position:absolute; width:100%; background-color: #dddddd; bottom:0; }
<footer> <p id="footername">Example Text</p> <p>Example Text</p> <p>Example Text</p> </footer>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.