有没有办法让Bootstrap手风琴在移动设备上工作?

时间:2015-09-25 23:39:05

标签: twitter-bootstrap-3 accordion

有没有办法只在移动设备上使用Bootstraps手风琴功能?在桌面设备中,我希望面板中的内容无需外部边框或手风琴功能即可显示。

2 个答案:

答案 0 :(得分:0)

最简单的方法是包含两个版本,但在桌面版本中添加一个响应实用程序类,以便在移动设备上隐藏它:

<div class="hidden-xs">
 // desktop version here
</div>

并将相应的类添加到移动版本以在移动设备上显示:

<div class="visible-xs-block">
 // mobile version here
</div>

这是documentation for responsive helper classes

答案 1 :(得分:0)

很抱歉回答这样一个老话题,但是在寻找快速解决方案时遇到了这个问题,以为我会分享我的想法。

//collapse BS accordions on page load in mobile view, and re-expands if screen size changes to tablet or desktop size $(window).on("load resize",function(){ var screenwidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; if (screenwidth <= 767) { $('.panel-collapse').removeClass('in'); $('a[aria-expanded="true"]').addClass("collapsed"); $('a[aria-expanded="true"]').attr("aria-expanded", "false"); } if (screenwidth >= 768) { $('#accordion1 .panel-collapse').addClass('in'); $('#accordion1 a[data-toggle="collapse"]').removeClass('collapsed'); $('#accordion1 a[data-toggle="collapse"]').attr("aria-expanded", "true"); } });

相关问题