html - 如果网页上除了单个标题之外没有其他内容,如何将文本保留在页脚附近
问题描述
我试图让我的 h1 保持在页脚附近而不在页眉上使用 margin-bottom 以便我的文本将保持在页脚附近 我想要这样的东西 在此处输入图像描述
我尝试过的解决方案是通过将 margin-bottom:515px 提供给标题,以便它保持在底部,但如果我知道任何更好的方法来实现这件事,我将不胜感激
解决方案
由于重叠问题,无法推荐绝对位置。Flex 会施展魔法。
body,
html {
margin: 0;
}
.header {
align-items: flex-end;
background-color: red;
display: flex;
height: calc(100vh - 100px);
}
h1 {
margin: 0 0 50px;
}
.footer {
align-items: center;
background-color: blue;
color: white;
display: flex;
height: 100px;
width: 100%
}
p {
margin: 0;
}
<div class="header">
<h1>H1 goes here</h1>
</div>
<div class="footer">
<p>footer goes here</p>
</div>
推荐阅读
- javascript - 如何在 console.log 中查看函数的输出?
- xml - 用于更新 XML 文件的 Powershell 脚本
- javascript - React TypeError:无法读取未定义的属性“nbaGames”
- java - 如何给面板内的列固定列宽?
- java - 控制语句抛出算术异常
- python - 以另外两列为条件更改现有列
- python - TypeError:转换时无法将 IntervalArray 转换为 dtype float64(pd.qcut,x)
- python-3.x - 为什么当 app.config["USE_X_SENDFILE"] 设置为 True 时,swagger 在浏览器中不显示任何内容?
- java - Sonarqube Maven 错误不在 git 树内
- html - 导航栏无法使用 bootstrap5 在移动设备上扩展