關于分辨率縮小時,list-group隱藏為按鈕的問題解決方法
回答了幾位同學,發現還有更多同學都有這個問題,干脆我統一回答了吧,希望能幫到大家
我查看了例子中的源碼,有個offcanvas.css和offcanvas.js需要加載。
offcanvas.css的源碼:
/*
?* Style tweaks
?* --------------------------------------------------
?*/
/*html,
body {
? overflow-x: hidden; ?Prevent scroll on narrow devices?
}
body {
? padding-top: 70px;
}
footer {
? padding: 30px 0;
}*/
/*
?* Off Canvas
?* --------------------------------------------------
?*/
@media screen and (max-width: 767px) {
? .row-offcanvas {
? ? position: relative;
? ? -webkit-transition: all .25s ease-out;
? ? ? ? ?-o-transition: all .25s ease-out;
? ? ? ? ? ? transition: all .25s ease-out;
? }
? .row-offcanvas-right {
? ? right: 0;
? }
? .row-offcanvas-left {
? ? left: 0;
? }
? .row-offcanvas-right
? .sidebar-offcanvas {
? ? right: -50%; /* 6 columns */
? }
? .row-offcanvas-left
? .sidebar-offcanvas {
? ? left: -50%; /* 6 columns */
? }
? .row-offcanvas-right.active {
? ? right: 50%; /* 6 columns */
? }
? .row-offcanvas-left.active {
? ? left: 50%; /* 6 columns */
? }
? .sidebar-offcanvas {
? ? position: absolute;
? ? top: 0;
? ? width: 50%; /* 6 columns */
? }
}
offcanvas.js的源碼:
$(document).ready(function () {
? $('[data-toggle="offcanvas"]').click(function () {
? ? $('.row-offcanvas').toggleClass('active')
? });
});
在 .html代碼中加載這兩個文件,樣式和行為才能起效。
貼兩個代碼片段,你可以根據這個代碼片段定位到你的代碼,做相應修改:
這里調用了樣式,button調用了data-toggle方法
<div class="container-fluid">
? <div class="row row-offcanvas row-offcanvas-right">
? ? <div class="col-sm-9">
? ? ? <p class="pull-right visible-xs">
? ? ? ? <button class="btn-xs btn btn-primary" data-toggle="offcanvas">Toggle</button>
? ? ? </p>
下面是list-group需要加載的樣式
<div class="col-sm-3 sidebar-offcanvas" id="sidebar">
? ? ? <ul class="list-group">