我刚访问这个页面
http://www.elmastudio.de/和想知道是否可能建立左侧边栏折叠与Bootstrap 3。
<button type="button" class="navbar-toggle sidebar-toggle" data-toggle="collapse" data-target=".sidebar-ex1-collapse"> <span class="sr-only">Sidebar</span> <span class="glyphicon glyphicon-check"></span> </button>
Sidebar本身有hidden-xs类。它用以下js删除
$('.sidebar-toggle').click(function(){ $('#sidebar').removeClass('hidden-xs'); });
解决方法
是的,这是可能的。这个例子应该有助于你开始..
基本上,您需要将布局包装在外部div中,并使用媒体查询在较小的屏幕上切换布局。
/* collapsed sidebar styles */ @media screen and (max-width: 767px) { .row-offcanvas { position: relative; -webkit-transition: all 0.25s ease-out; -moz-transition: all 0.25s ease-out; transition: all 0.25s ease-out; } .row-offcanvas-right .sidebar-offcanvas { right: -41.6%; } .row-offcanvas-left .sidebar-offcanvas { left: -41.6%; } .row-offcanvas-right.active { right: 41.6%; } .row-offcanvas-left.active { left: 41.6%; } .sidebar-offcanvas { position: absolute; top: 0; width: 41.6%; } #sidebar { padding-top:0; } }