html - 在 Bootstrap 仪表板模板示例中设置特定的侧边栏宽度

标签 html css twitter-bootstrap twitter-bootstrap-3

我正在使用 Bootstrap 附带的仪表板模板示例。侧边栏在一定屏幕尺寸后消失,这很好。但是我想在那之前设置一个特定的宽度。现在它在更大的屏幕上具有响应性和宽度拉伸(stretch)(在大显示器上有点令人讨厌。)一个好的宽度是 250px

CSS

/*
 * Base structure
 */

/* Move down content because we have a fixed navbar that is 50px tall */
body {
  padding-top: 50px;
}


/*
 * Global add-ons
 */

.sub-header {
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}


/*
 * Sidebar
 */

/* Hide for mobile, show later */
.sidebar {
  display: none;
}
@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; /* Scrollable contents if viewport is shorter than content. */
    background-color: #31373d;
    border-right: 1px solid #eee;
  }
}

/* Sidebar navigation */
.nav-sidebar {
  margin-right: -21px; /* 20px padding + 1px border */
  margin-bottom: 20px;
  margin-left: -20px;
}
.nav-sidebar > li > a {
  padding-right: 20px;
  padding-left: 20px;
  color: #98a7b5;
}

.nav-sidebar > li > a:hover {
    background: transparent;
    color: #fff;
}

.nav-sidebar > .active > a, .nav-sidebar > li > a:hover {
  color: #fff;
  background-color: #272c30;
}


/*
 * Main content
 */

.main {
  padding: 20px;
}
@media (min-width: 768px) {
  .main {
    padding-right: 40px;
    padding-left: 40px;
  }
}
.main .page-header {
  margin-top: 0;
}


/*
 * Placeholder dashboard ideas
 */

.placeholders {
  margin-bottom: 30px;
  text-align: center;
}
.placeholders h4 {
  margin-bottom: 0;
}
.placeholder {
  margin-bottom: 20px;
}
.placeholder img {
  display: inline-block;
  border-radius: 50%;
}

有什么想法吗?谢谢。 源代码可在 getbootstrap.com 获得

最佳答案

.sidebar CSS 中的 max-width: 250px 怎么样?

关于html - 在 Bootstrap 仪表板模板示例中设置特定的侧边栏宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22787165/

相关文章:

按钮单击时的 JqueryUI 工具提示而不是悬停显示在其他地方

PHP - 将输入字段列表输入数据库

javascript - 使用jquery从组中获取组成员

css - 打印 Bootstrap 页面时的颜色问题

javascript - 无法使用 Bootstrap Carousel 读取未定义的属性 'offsetWidth'

jquery - 实现e.pageX和e.pageY时html属性 "id"和 "class"有什么区别

html - 使用 -webkit-transform 时固定位置不起作用

HTML/CSS - 跨越整个标题的 Logo 链接

css - CSS 迷宫破解是如何工作的?

javascript - 将预定义的颜色序列应用于动态元素列表