我几乎完成了网页,我知道如何折叠内容,但我仍然不知道如何直接显示内容,但在移动设备中以手风琴风格显示它们而不重复它。
这是我的代码,我使用Bootstrap来制作手风琴。
<div class="container">
<div class="panel-group" id="accordion">
<div class="panel panel-default hidden-xs">
<div class="panel-heading">
<h4 class="panel-title ">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse1" >Collapsible Group 1</a>
</h4>
</div>
<div id="collapse1" class="panel-collapse collapse">
<div class="panel-body">
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse2">Collapsible Group 2</a>
</h4>
</div>
<div id="collapse2" class="panel-collapse collapse">
<div class="panel-body">
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse3">Collapsible Group 3</a>
</h4>
</div>
<div id="collapse3" class="panel-collapse collapse">
<div class="panel-body">
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</div>
</div>
</div>
</div>
</div>
答案 0 :(得分:0)
如果您无法复制内容并使用引导程序隐藏的帮助程序类,那么您可以使用javascript执行此操作。
首先,删除在所有屏幕尺寸上初始化手风琴的数据属性。
其次,根据屏幕尺寸初始化手风琴。
if ($(window).width() < 960) {
$('#accordion').find('.panel-collapse').addClass('collapse')
$('#accordion').find('.panel-title a').attr('data-toggle','collapse')
$('#accordion').collapse()
}