html - 我怎样才能让我的 Bootstrap 导航栏背景颜色跨越我页面的整个宽度?

标签 html css twitter-bootstrap navbar

我这里有一个显示导航栏的 fiddle 。导航栏跨越页面的大部分但不是全部。我希望背景颜色跨越页面的整个宽度(不是链接,只是背景颜色,所以 width: 100% on background color,但我尝试了 menupartial width 100% 并且它在 css 中不起作用。这里是我的 Fiddle

body {
  padding-top: 51px;
  /*padding-bottom: 20px;*/
}
/* Set padding to keep content from hitting the edges */

.front-page-body-content {
  padding-left: 15px;
  padding-right: 15px;
}
/* Override the default bootstrap behavior where horizontal description lists 
   will truncate terms that are too long to fit in the left column 
*/

.dl-horizontal dt {
  white-space: normal;
}
/* Set width on the form input elements since they're 100% wide by default */

input,
select,
textarea {
  max-width: 280px;
}
.navbar-inline {
  display: inline-flex;
}
#navbarSearchQuery {
  float: left;
  margin-top: 8px;
  margin-left: 15px;
  min-width: 280px;
}
@@media only screen and (max-width:768px) {
  #navbarSearchQuery {
    min-width: 240px;
  }
}
#searchQuery {
  /*float: left;*/
  margin-top: 10px;
  /*margin-left: 15px;*/
  min-width: 280px;
}
a.navbar-brand {
  padding-top: 10px;
  padding-bottom: 10px;
}
form#queryWithin {
  max-height: 50px;
}
#ClassDate {
  cursor: default;
}
.menupartial {
  background-color: #16749F;
  opacity: .9;
  width: 100%;
}
.menupartial a {
  color: lightgrey;
  font-weight: bold;
}
.nav-pills > li > a {
  border-radius: 0;
}
.nav-pills > li > a:hover {
  border-radius: 0;
  background-color: #16749F;
  color: white;
}
.nav-pills > li > a:active {
  border-bottom: 5px solid white;
}
<body>
  <div class="container body-content">
    <div class="row menupartial">
      <div class="col-md-12">
        <ul class="nav nav-pills">

          <li><a href="#">Your Schedules</a>
          </li>
          <li><a href="#">Your Messages</a>
          </li>
          <li><a href="#">Your Groups</a>
          </li>
          <li><a href="#">Your Friends</a>
          </li>
        </ul>
      </div>
    </div>
  </Div>
</body>

最佳答案

container 更改为 container-fluid 并将 menupartial 移动到该 div,如下所示:

<div class="container-fluid menupartial">

container-fluid 是默认的 Bootstrap 类,用于将容器跨越到全 Angular 。

这是一个包含上述类的 jsFiddle:http://jsfiddle.net/AndrewL32/65sf2f66/49/

关于html - 我怎样才能让我的 Bootstrap 导航栏背景颜色跨越我页面的整个宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32597215/

相关文章:

javascript - 以 "verification"模态显示形式和内容

javascript - 推特 Bootstrap : Select Box vs DropDown

javascript - php脚本邮件程序模式 Bootstrap

javascript - 给定形状列表动态创建的复杂 HTML 网格

javascript - 我怎样才能使这个活跃的点击?

asp.net - RadioButton 控件控件下的文字换行

css - 搜索引擎会看到 CSS 生成的内容吗?

python - 为网络格式化 Python 代码

html - 让第二行填补上面的空白

html - 垂直对齐中间问题