所以我有这个 HTML 页面,其中有 3 个主要元素,一个侧面导航栏、一个标题和一个数据部分,出于某种原因,它们都是绝对定位的。简而言之,它看起来像这样:
html{
height: 100%;
}
body{
height: 100%;
}
header{
position: absolute;
width: 100%;
height: 144px;
top: 0;
}
.data {
position: absolute;
width: 100%;
min-height: calc(100vh - 192px);
top: 168px;
}
<html>
<head></head>
<body>
<header></header>
<div class="data"><div>
</body>
</html>
我需要在页眉和 .data 之间以及数据和页面底部之间留出 24px 的边距。在我将更多内容插入 .data 以使其超出指定的最小高度之前,它工作正常。所以我失去了页面的底部边距。我尝试使用 :after 添加内容,但没有成功。有什么建议么? 干杯。
最佳答案
在 css 中的 .data 类中添加边距底部
.data {position: absolute; width: 100%; min-height: calc(100vh - 192px); top: 168px; margin:0 0 24px 0;}
关于html - 将 padding-bottom 添加到所有元素都绝对定位的页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53995299/