html - 如何用背景色填充整个div

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

我试图在 bootstrap 中获取背景色来填充子 div 中的整个 div,但我完全卡住了。我希望右边的部分是黄色的,但它只是突出显示了 div 中的文本。

这是一个 fiddle .

我知道我遗漏了一些非常明显的东西,但我如何让黄色填充整个 col-lg-6 div?

.new-section {
  height: 100%;
  padding-top: 150px;
  text-align: center;
  background: #eee;
}

.yellow {
  background-color: yellow;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>

<section id="new" class="new-section">
  <div class="container">
    <div class="row">
      <div class="col-lg-6">
        <h1>Section left</h1>
      </div>
      <div class="col-lg-6 yellow">
        <h1>Section right</h1>
      </div>
    </div>
  </div>
</section>

最佳答案

发生这种情况是因为您将 .col-lg-*.container 一起使用,它只有 width:1170px

所以将 .container 更改为 .container-fluid

bootstrap docs 中查看有关容器的更多信息

.new-section {
  height: 100%;
  padding-top: 150px;
  text-align: center;
  background: #eee;
}
.yellow {
  background-color: yellow;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<!-- New Exhibit Section -->
<section id="new" class="new-section">
  <div class="container-fluid">
    <div class="row">
      <div class="col-xs-6 col-lg-6">
        <h1>Section left</h1>
      </div>

      <div class="col-xs-6 col-lg-6 yellow">
        <h1>Section right</h1>
      </div>
    </div>
  </div>
</section>

关于html - 如何用背景色填充整个div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38017917/

相关文章:

jquery - 显示从无更改为阻止时的事件监听器

android - MonoDroid : Missing Button. SetText(跨度)

html - 使用 css 编辑标题

javascript - 单击或退出键关闭叠加层

css - Twitter Bootstrap 下拉菜单

html - 如何更改 Angular 主题的默认文本颜色?

html - Bootstrap 4 : make a responsive "pixelart" DIV

html - 去除两个梯形之间的空间

html - Angular 属性无法设置未定义的属性

html - 背景图像获取 "zoomed in"