首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何减少Bootstrap 4列表组中的间距

如何减少Bootstrap 4列表组中的间距
EN

Stack Overflow用户
提问于 2019-11-14 01:37:22
回答 1查看 3.3K关注 0票数 0

我有一个列表组,但是我想降低每个列表组项目之间的直线高度。我尝试了下面的内容,但是最后一个li的格式是关闭的,因为边距底部没有被应用。

CSS

代码语言:javascript
复制
 .list-group-item{
        margin-bottom: -6px;
        margin-top: -6px;  
    }

代码语言:javascript
复制
 <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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-11-14 01:49:52

您可以尝试将my-auto替换为对inputlabel元素的另一个边距-x设置,如下所示:

代码语言:javascript
复制
<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-0my-1,.,直到my-5助手类。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58848127

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档