html - 为什么我的页脚周围有一个空框?
问题描述
我试图在页面底部放置一个页脚,但最终在底部出现了不需要的空白。我该如何纠正?以下是我的 HTML 和 CSS:
body{
min-height:100vh;
position:relative;
}
.page-wrap{
padding-bottom:50px;
}
footer{
position:absolute;
background-color:red;
bottom:0;
width:100%;
height:50px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div class="page-wrap">
<nav>
<h2>Header</h2>
</nav>
<main>
<h2>Content</h2>
</main>
</div>
<footer><h2>Footer</h2></footer>
</body>
</html>
我不确定是什么在创造它。
解决方案
只需添加下面提到的 CSS 代码。希望这对您有所帮助。
footer h2 { margin: 0; }
推荐阅读
- julia - 在 Julia 的 CSV 文件中解析 DateTime
- javascript - 使用嵌套的 for 循环更改数组内的对象键
- python - 如何通过在 Pandas 中按一列分组并匹配另一列来获取转换后的数据框
- mysql - AWS RDS-MySQL 显示比预期/实际数据库大小更多的存储使用量
- r - 将汇总的数据整理成整齐的格式
- python - 如何通过单击 GUI 中的按钮来创建新的数据图窗口
- javascript - 如果表格只有一行,则 HTML 表格中的列宽会发生变化
- java - API在android studio中不断返回401,但在浏览器中返回ok
- ruby - Rails 正在使用 .html_safe 转义视图中的 erb 行
- python - 计算每个键的出现次数