有一个BS4折叠式,希望在用户向下滚动时将打开的标题保持在顶部,因此折叠式打开的标题的粘滞行为
实际方法不起作用:
#accordion .card-header BUTTON:not(.collapsed) {
position: -webkit-sticky; /* Safari */
position: sticky;
top: 0;
}
页眉保持在屏幕上不可见
代码:
<style>
#accordion .card-header BUTTON:not(.collapsed) {
position: -webkit-sticky; /* Safari */
position: sticky;
top: 0;
}
</style>
<div id="accordion" class="groups">
<div class="card">
<div class="card-header d-block d-md-none m-0 p-0">
<h2 class="mb-0">
<button
class="btn btn-link btn-block p-2"
data-toggle="collapse"
data-target="'#group-1"
aria-controls="'#group-1"
>title</button>
</h2>
</div>
<div id="group-1" class="collapse" aria-labelledby="headingOne" data-parent="#accordion">
...
</div>
</div>
</div>
1条答案
按热度按时间6tr1vspr1#
通过给出z-index来尝试:1000;在css中为#accordion .card-header BUTTON:不(.折叠)