html - 如何减少 Bootstrap 4 列表组中的间距
问题描述
我有一个列表组,但我想减少每个列表组项之间的行高。我在下面尝试了以下操作,但最后一个 li 的格式已关闭,因为未应用边距底部。
CSS
.list-group-item{
margin-bottom: -6px;
margin-top: -6px;
}
HTML
<ul class="list-group ml-3 mr-3 mt-1 sidebar-list-items ">
<li class="list-group-item d-flex p-0 border-0" >
<input class="my-auto ml-2" type="checkbox" id="CheckBox1" />
<label style="font-size: 13px;"class="mt-2 ml-2 w-100 " for="CheckBox1">Acupunture</label>
</li>
<li class="list-group-item d-flex p-0 border-0">
<input class="my-auto ml-2" type="checkbox" id="CheckBox2" />
<label style="font-size: 13px" class=" mt-2 ml-2 w-100" for="CheckBox2">Ayurveda </label>
</li>
<li class="list-group-item d-flex p-0 border-0 ">
<input class="my-auto ml-2" type="checkbox" id="CheckBox3" />
<label style="font-size: 13px" class="mt-2 ml-2 w-100" for="CheckBox3">Homeopathy</label>
</li>
</ul>
解决方案
您可以尝试用和元素my-auto
上的另一个 margin-x 设置替换,如下所示:input
label
<ul class="list-group ml-3 mr-3 mt-1 sidebar-list-items ">
<li class="list-group-item d-flex p-0 border-0" >
<input class="ml-2 my-0" type="checkbox" id="CheckBox1" />
<label style="font-size: 13px;"class="my-0 ml-2 w-100 " for="CheckBox1">Acupunture</label>
</li>
<li class="list-group-item d-flex p-0 border-0">
<input class="my-0 ml-2" type="checkbox" id="CheckBox2" />
<label style="font-size: 13px" class=" my-0 ml-2 w-100" for="CheckBox2">Ayurveda </label>
</li>
<li class="list-group-item d-flex p-0 border-0 ">
<input class="my-0 ml-2" type="checkbox" id="CheckBox3" />
<label style="font-size: 13px" class="my-0 ml-2 w-100" for="CheckBox3">Homeopathy</label>
</li>
</ul>
您可以尝试my-0
, my-1
, ... 中的一种,直至my-5
辅助类。
推荐阅读
- javascript - 如何设置onclick验证javascript的条件
- entity-framework - ASP.NET Core Entity Framework 连接字符串超过 1 个登录用户
- python - pytorch中的坐标图像识别
- apache-spark - 将 Spark 作业远程提交到独立集群
- java - 在 Java 开发过程中如何正确绕过 reCAPTCHA
- python - 不知道为什么会这样?
- http - 如果客户端发送连接关闭标头,服务器是否可以与有效负载产生共鸣?
- python-3.x - 我需要创建一个 pyspark UDF,它通过比较从查询中输出一个表
- javascript - 将mysql查询行存储在变量中以供以后在另一个mysql查询中使用
- html - Django ManyToMany 查询,传递给 HTML