所以我的页面上有一个tablist,在每个标签内部,我需要一个手风琴,因为我有很多信息输出给用户。我的问题是,当页面加载时,手风琴不会折叠起来。即使aria-expanded
设置为false
,它们也会全部展开。当我单击标题然后关闭该部分时,它会显示它将播放的动画,就像它正在展开一样。再次单击它,它会关闭。这是我的测试代码:
<ul class="nav nav-pills" role="tablist">
<li role="presentation" class="active"><a href="#open" aria-controls="open" role="tab" data-toggle="tab">Open Tickets</a></li>
</ul><br>
<!--The Tab Contents-->
<div class="tab-content">
<div role="tabpanel" class="tab-pane fade in active" id="open">
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-info">
<div class="panel-heading" role="tab" id="headingOne">
<span>
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="false" aria-controls="collapseOne">Info One</a>
</span>
</div>
<div id="collapseOne" class="panel-collapse" role="tabpanel" aria-labelledby="headingOne">
<div class="panel-body">
Content Here
</div>
</div>
</div>
<div class="panel panel-info">
<div class="panel-heading" role="tab" id="headingTwo">
<span>
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">Info One</a>
</span>
</div>
<div id="collapseTwo" class="panel-collapse" role="tabpanel" aria-labelledby="headingTwo">
<div class="panel-body">
Content Here
</div>
</div>
</div>
<div class="panel panel-info">
<div class="panel-heading" role="tab" id="headingThree">
<span>
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree">Info One</a>
</span>
</div>
<div id="collapseThree" class="panel-collapse" role="tabpanel" aria-labelledby="headingThree">
<div class="panel-body">
Content Here
</div>
</div>
</div>
</div>
</div>
</div>
因此,它是一个嵌套在标签组中的手风琴,或者是我在看的东西。
答案 0 :(得分:3)
您需要将.collapse
课程添加到.panel-body
的父级div:
<div id="collapseOne" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne">
<div class="panel-body">
Content Here
</div>
</div>