代码之家  ›  专栏  ›  技术社区  ›  user2470889189

删除Bootstrap的v4.3.1填充内联启动

  •  0
  • user2470889189  · 技术社区  · 5 月前

    我正在尝试删除Bootstrap的默认设置 padding-inline-start: 40px; 我的财产 <ol> 的列表项在特定类中。我试过:

    .myclass ol {
        display: block;
        list-style-type: none;
        padding-inline-start: 0px;
        padding-left: 0px;
    }
    

    在HTML中用作:

    <ol class="mb-4 myclass">
        <!-- the rest of the code -->
    </ol>
    

    所有列表项的左侧填充仍然保留。如何删除它?

    2 回复  |  直到 5 月前
        1
  •  1
  •   user28747840    5 月前

    你的CSS代码没有正确地针对HTML中的内容。 CSS应该是:

    ol.myclass  {
      display: block;
      list-style-type: none;
      padding-inline-start: 0px;
      padding-left: 0px; 
    }
    

    有时,您可能需要增加 Specificity 您的规则可以覆盖引导程序中的某些内容 作为最后的手段,您可以使用 !important 执行你的规则。但尽量避免这种情况。

        2
  •  1
  •   Kostas Minaidis    5 月前

    更改 .myclass ol ol.myclass 选择器。

    .myclass ol 正在瞄准所有人 <ol> 元素内部的元素 .myclass 类名。

    你想要的是 <ol> 具有以下特征的元素 .myclass 类。

    .myclass ol {
      ...
    }
    

    =>

    ol.myclass {
      ...
    }