为了账号安全,请及时绑定邮箱和手机立即绑定

关于分辨率缩小时,list-group隐藏为按钮的问题解决方法

2017.03.19 00:47 2075浏览

默认样式

屏幕分辨率缩小时,右上角出现按钮

点击按钮,右侧菜单滑出

查看了例子中的源码,有个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代码中加载这两个文件,样式和行为才能起效。
两个代码片段中对offcanvas的引用,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">
点击查看更多内容
2人点赞

若觉得本文不错,就分享一下吧!

评论

相关文章推荐

正在加载中
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消