我再一次遇到了脚注标签的问题。我想让这个部分适合整个屏幕。但不是身体的另一部分。这就是为什么我没有在正文元素中放边距:0;的原因。
我试着将页脚边距:0设置为footer,但它不起作用(如图所示)。我该如何解决这个问题。
我的页脚css文件
footer{
padding: 5vw;
margin:0px;
background-color: #DCEDC8;
color: black;
font-size: 4vw;
text-align: center;
font-weight: bold;
}
1:https://i.stack.imgur.com/kCczY.jpg footer doesn't fit to the screen properly
发布于 2021-04-25 20:47:04
您目前遇到的问题是,body
默认设置了页边距,因此body标记中的任何元素(包括页脚!)也将受到该利润率的影响。
要解决这个问题,您可以将margin: 0
应用于body,并将所有内容放入容器div (其中有一些空白处)。
然后,将你的页脚放在容器的外面,并将它的边距也设置为0。
body {
margin: 0;
}
.container {
margin: 8px;
background-color: #9f9f9f;
}
footer {
margin: 0;
background-color: #ff5555;
}
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div class="container">
Your content goes here. Notice that there is a margin surrounding this div.
</div>
<footer>
Your footer goes here. Notice that there is no margin surrounding this footer.
</footer>
</body>
</html>
https://stackoverflow.com/questions/67257776
复制相似问题