css 删除Bootstrap 5折叠按钮的轮廓

yk9xbfzb  于 2023-02-01  发布在  Bootstrap
关注(0)|答案(3)|浏览(133)

当你 checkout Bootstrap 5 accordion时,你会看到一个轮廓。我想删除它。我不确定是哪个元素实际上产生了轮廓,但我怀疑是button。无论如何,我已经尝试将以下内容应用于所有可能的元素:

.accordion-item, .accordion-item:focus, .accordion-item:active,
.accordion-header, .accordion-header:focus, .accordion-header:active,
.accordion-button, .accordion-button:focus, .accordion-button:active {
  outline: none !important;
}

好像什么都不管用。有什么办法吗?
下面是html代码的副本:

<div class="accordion" id="accordionExample">
  <div class="accordion-item">
    <h2 class="accordion-header" id="headingOne">
      <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
        Accordion Item #1
      </button>
    </h2>
    <div id="collapseOne" class="accordion-collapse collapse show" aria-labelledby="headingOne" data-bs-parent="#accordionExample">
      <div class="accordion-body">
        ...
      </div>
    </div>
  </div>
</div>
j91ykkif

j91ykkif1#

若要删除阴影和蓝色边框颜色...

.accordion-button:focus {
    box-shadow: none;
    border-color: rgba(0,0,0,.125);
}

Demo

aurhwmvo

aurhwmvo2#

您可以使用

.accordion-button:not(.collapsed){
        box-shadow: none;
    }
sqxo8psd

sqxo8psd3#

在这里它将工作:

.accordion-item {
  border: none;
}

相关问题