我正在尝试制作一个手风琴,其中只有几个用子元素扩展的项目和 2 个没有子元素的项目,这些项目会关闭任何打开的东西。
您可以在项目 #3 上看到 .accordion-inner div 中有内容,但我不希望显示该内容。您还将在项目#4 上看到#collapseFour 内没有完全破坏手风琴的.accordion-inner。
问题 1:Twitter Bootstrap 手风琴可以做到这一点吗?
问题 2:有没有更好的方法来处理这个过程?
代码:
<div class="accordion" id="accordion2">
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
Collapsible Group Item #1
</a>
</div>
<div id="collapseOne" class="accordion-body collapse in">
<div class="accordion-inner">
Anim pariatur cliche...
</div>
</div>
</div>
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo">
Collapsible Group Item #2
</a>
</div>
<div id="collapseTwo" class="accordion-body collapse">
<div class="accordion-inner">
Anim pariatur cliche...
</div>
</div>
</div>
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseThree">
Collapsible Group Item #3
</a>
</div>
<div id="collapseThree" class="accordion-body collapse">
<div class="accordion-inner">
This is where i do not need child elements
</div>
</div>
</div>
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseFour">
Collapsible Group Item #4
</a>
</div>
<div id="collapseFour" class="accordion-body collapse">
</div>
</div>
</div>