我正在尝试获取背景颜色以填充引导程序中子 div 中的整个 div,但我完全卡住了。我希望右边的部分是黄色的,但它只是突出显示了 div 中的文本。
这是一个 小提琴。
我知道我遗漏了一些非常明显的东西,但是如何让黄色填充整个 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>
原文由 hcgriggs 发布,翻译遵循 CC BY-SA 4.0 许可协议
发生这种情况是因为您正在使用
.col-lg-*
和.container
只有width:1170px
所以改变
.container
到.container-fluid
在 bootstrap 文档 中查看有关容器的更多信息