Reputation: 190
I'm trying to get a background color to fill the entire div in a child div in bootstrap, but I'm completely stuck. I want the right section to be yellow, but it's only highlighting the text in the div.
Here's a fiddle.
I know I'm missing something really obvious, but how do I get yellow to fill the entire 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>
Upvotes: 9
Views: 52784
Reputation: 67778
Keep in mind that h1
has top and bottom margins that will be taken over by its wrapper and will not be affected by background-color since they are outside of the block element. You could remove the h1 tag and style the parent container in a similar way (but using padding instead of margins):
https://jsfiddle.net/j33wz2o6/1/
Upvotes: 0
Reputation: 60563
This is happening because you are using .col-lg-*
with .container
which only has width:1170px
So change .container
to .container-fluid
See more info about containers in 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>
Upvotes: 7