【问题标题】:Making the Bootstrap dashboard example sidebar visible/available on mobile使 Bootstrap 仪表板示例侧边栏在移动设备上可见/可用
【发布时间】:2014-05-24 00:03:15
【问题描述】:

当屏幕宽度小于 768 像素时,Boostrap dashboard example 将侧边栏导航完全隐藏(不折叠或堆叠)。您将如何通过这样的设置支持移动设备?

【问题讨论】:

  • 为了让它对移动设备友好,只需要删除 .sidebar 类;主容器上的负偏移量(sm-md-offset-2sm);从而将侧边栏转换为网格列。由您决定是否希望它出现在主容器的上方或下方。
  • 谢谢,@MackieeE。那行得通,作为答案发布!
  • @eithe 我将扩展 SW4 的 =)

标签: html css twitter-bootstrap


【解决方案1】:

引导程序 4

Create a responsive navbar sidebar "drawer" in Bootstrap 4?

引导程序 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;
}

【讨论】:

  • 这是一个更好的示例,可以更准确地将原始页面转换为移动视图。
【解决方案2】:

“大于”移动视图侧边栏的 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;
   }

之后它恢复到默认的display:none

.sidebar {
   display: none;
}

您需要更改其默认 CSS,或添加新的 media query,例如

@media (max-width: 768px)

为了专门针对较小的设备。您希望应用的样式类型取决于您所追求的。

【讨论】:

  • 谢谢,你会推荐什么?叠吗?崩溃到某个地方?我更喜欢折叠,但顶部的主标题已经折叠在正常位置..
  • 它非常主观,可能会折叠并堆叠在主菜单下方..?
  • 一个选项是简单地将其隐藏在屏幕左侧,然后提供一个小的抓取器手柄(类似于汉堡菜单在主导航中的工作方式)以显示它。显示时,它会从后台向左滑动以填充窗口并根据需要滚动,直到被用户关闭/折叠。
猜你喜欢
  • 2019-05-17
  • 2012-09-17
  • 1970-01-01
  • 1970-01-01
  • 2020-12-03
  • 1970-01-01
  • 2018-01-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多