html - 父级中的最后一个元素 - 边距未生效?
问题描述
<p>
最后一个元素是a还是等都没关系,<h1>
为什么最后一个元素的margin没有生效?
它应该将父容器背景向下推。
.container {
background: grey;
}
h1 {
margin-bottom: 3em
}
p {
margin-bottom: 5em
}
<div class="container">
<h1>Title</h1>
<p>Content.</p>
</div>
解决方案
只需使用填充在框中创建空间。谷歌关于盒子模型。
.container {
background: grey;
}
h1 {
margin-bottom: 3em
}
p {
padding-bottom: 5em
}
<div class="container">
<h1>Title</h1>
<p>Content.</p>
</div>
推荐阅读
- flutter - 如何正确阅读 ModalRoute.of(context).settings.arguments?
- laravel - Laravel 上传多个文件
- html - 防止文本破坏 flexbox 容器
- javascript - 使用reactjs在Safari中滚动页面后单击事件不起作用
- jquery - 在 Google Chrome 中更改 GIF 图片 src 会使图片卡顿
- python-3.x - 如何使用 Selenium 获取 html 代码中的文本?
- laravel - 我想将数据从一个视图发送到另一个 Laravel 视图
- javascript - How to select a specific row from some same class name of a table using jQuery
- java - 如何在 Java 中获取属性的所有者类?
- java - 如何在 .dxf 中为 Groupcode 1001 获取/设置应用程序名称?