首页 > 解决方案 > 即使定义了边距等,页脚也不会到达边缘?

问题描述

我在这里开始感到疯狂。即使已定义,我的页脚也不会到达窗口边缘(至少我是这么认为的)

.footer {
  height: 200px;
  bottom: 0px;
  margin: 0px;
  left: 0px;
  right: 0px;
  padding: 0px;
  width: 100%;
  background-color: #E5E5E5;
  text-align: center;
}
<footer>
  <div class="footer">
    <p>Footer</p>
  </div>
</footer>

标签: htmlcss

解决方案


我从 html 和 body 标签中删除了边距

 html,body{
    margin:0;
 }
.footer {
	height: 200px;
	bottom: 0px;
	margin: 0px;
	left:0px;
	right:0px;
	padding: 0px;
	width: 100%;
    background-color: #E5E5E5;
    text-align: center;
}
<footer>
	<div class="footer">
		<p>Footer</p>
	</div>
</footer>


推荐阅读