html - 使用引导程序的 div 之间的 Html css 空间
问题描述
我有一行使用引导程序,我想在每个部分之间添加空间,除了第一个和最后一个孩子。但是,我的代码导致行溢出。
HTML:
<div class="row">
<div class="col-md-4 section">
hello
</div>
<div class="col-md-4 section">
hello
</div>
<div class="col-md-4 section">
hello
</div>
</div>
CSS:
.section{
background-color: red;
margin-left: 5px;
margin-right: 5px;
}
.section:first-of-type{
margin-left: 0px;
margin-right: 0px;
background-color: green;
}
.section:last-of-type{
margin-left: 0px;
margin-right: 0px;
background-color: blue;
}
输出:
Hello Hello
Hello
解决方案
使用 bootstrap V4,您只需使用以下命令即可轻松完成此操作col
:
.section {
background-color: red;
margin-left: 15px;
margin-right: 15px;
}
.section:first-of-type {
margin-left: 0px;
margin-right: 0px;
background-color: green;
}
.section:last-of-type {
margin-left: 0px;
margin-right: 0px;
background-color: blue;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet">
<div class="container-fluid">
<div class="row">
<div class="col section">
hello
</div>
<div class="col section">
hello
</div>
<div class="col section">
hello
</div>
</div>
</div>
推荐阅读
- vb.net - 未找到类型“String()”的公共成员“包含”
- javascript - DailyCodingProblem,在数组中找到与给定值匹配的对
- python-3.x - python 3.6 pandas有条件地填充缺失值
- python - 如何在 plotly 和 numpy 中操作 json?
- c# - 获取 Null 时序列不包含任何元素
- ios - 无法从 json 数组中删除正确的对象
- java - 仅当满足特定的布尔情况时才返回 Observable
- amazon-web-services - 如果 RDS 实例已存在,使用 Boto3 检查的最佳方法是什么?
- docker - Docker:通过命令行查找是否启用了共享驱动器以及启用了哪些共享驱动器
- hadoop - 运行 TraceBuilder 以转换 JobHistory 文件