css - 导航栏中的列显示不在全宽容器中

标签 css twitter-bootstrap bootstrap-4

我想在我的页面上添加一个粘性标题,bootstrap 为其提供了一个类,我还添加了一个容器来使内容居中并使其与下面的内容一样宽。

但是当我添加一行和 12 列时,并没有占用容器的整个宽度,请参见下面的代码。

<nav class="navbar fixed-top navbar-light sticky-header">
      <div class="container sticky-header-container">
          <div class="row">
              <div class="col-md-3">test3
              </div>
              <div class="col-md-6">test2
              </div>
              <div class="col-md-3">test3
              </div>                    
          </div>
      </div>
</nav>

enter image description here

最佳答案

您可以像这样向您的行添加一个类:

编辑:正如 ZimSystem 指出的那样, Bootstrap 中有一个 w-100 类,所以就这样做:

<div class="row w-100">
   Your Elements
</div>

这应该让您获得 100% 的容器宽度。

工作样本:https://www.bootply.com/J5gKTedgPr

关于css - 导航栏中的列显示不在全宽容器中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48683629/

相关文章:

html - 如何将内容集中在表单中

html - 黄色下划线 CSS 随机未应用于跨度的全宽

css - 如何在 Bootstrap 中连续拉伸(stretch)图像

javascript - Bootstrap 弹出模式在我的网页上不起作用

css - 数据表隐藏的 Bootstrap4 下拉列表

css - 像启动画面一样的背景图像

css - 悬停时停止 href 文本颜色更改

php - 通过 ajax 将 JSON(从 php)打印到 Bootstrap 模式

jquery - Bootstrap 在页面加载时自动选择选项卡

css - 在 Chrome 中使用 Bootstrap 粘性导航栏的 1px 空间