使Bootstrap仪表板示例侧栏在移动设备上可见/可用

Eir*_*k H 8 html css twitter-bootstrap

当屏幕宽度小于768px时,Boostrap仪表板示例完全隐藏侧边栏导航(不折叠或堆叠).您如何通过这样的设置支持移动设备?

Zim*_*Zim 10

Bootstrap 4

在Bootstrap 4中创建响应式导航栏侧边栏"抽屉"?

Bootstrap 3

另一种选择是组合仪表板和"画布外"侧边栏模板.这种布局允许侧栏在较小的宽度上切换到屏幕上/屏幕上...

http://bootply.com/128936

@media screen and (max-width: 768px) {
  .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-left
  .sidebar-offcanvas {
    left: -33%;
  }

  .row-offcanvas-left.active {
    left: 33%;
  }

  .sidebar-offcanvas {
    position: absolute;
    top: 0;
    width: 33%;
    margin-left: 10px;
  }
}


/* Sidebar navigation */
.nav-sidebar {
  background-color: #f5f5f5;
  margin-right: -15px;
  margin-bottom: 20px;
  margin-left: -15px;
}
.nav-sidebar > li > a {
  padding-right: 20px;
  padding-left: 20px;
}
.nav-sidebar > .active > a {
  color: #fff;
  background-color: #428bca;
}
Run Code Online (Sandbox Code Playgroud)


SW4*_*SW4 4

“大于”移动视图侧边栏的 CSS 在以下位置指定:

@media (min-width: 768px)
   .sidebar {
      position: fixed;
      top: 51px;
      bottom: 0;
      left: 0;
      z-index: 1000;
      display: block;
      padding: 20px;
      overflow-x: hidden;
      overflow-y: auto;
      background-color: #f5f5f5;
      border-right: 1px solid #eee;
   }
Run Code Online (Sandbox Code Playgroud)

之后它恢复为默认值display:none

.sidebar {
   display: none;
}
Run Code Online (Sandbox Code Playgroud)

您需要更改其默认 CSS,或添加新的媒体查询,例如

@media (max-width: 768px)

为了专门针对较小的设备。您想要应用的样式类型取决于您的需求。