父盒子:
类名:accordion
id:accordionExample
子项目的折叠盒子的 data-bs-parent 需要与父盒子id一致
子项目:
类名:accordion-item
子项目头部:
类名:accordion-header
id:headingOne
子项目内容盒子的 aria-labelledby 需要与头部id一致
按钮的类名:accordion-button
按钮的属性:
data-bs-toggle=”collapse”切换
data-bs-target=”#collapseOne”
aria-expanded=”true”默认是否展开
aria-controls=”collapseOne”
子项目body
类名:accordion-body
省略这个属性,展开后需要手动关闭data-bs-parent
<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">
标题 #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 class="accordion-item">
<h2 class="accordion-header" id="headingTwo">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
标题 #2
</button>
</h2>
<div id="collapseTwo" class="accordion-collapse collapse" aria-labelledby="headingTwo" data-bs-parent="#accordionExample">
<div class="accordion-body">
内容
</div>
</div>
</div>
</div>
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容