Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 3 full width div's in container-fluid

I'm trying to create some "horizontal bands" in a Bootstrap 3 CSS layout, extending to the whole size of the browser's window, and thus outside of the content class margins. Here is a Plunker: http://plnkr.co/edit/6SlNU0ZgFehrBD64r9FG . I found that I can accomplish this by using a container-fluid class: this implies having a div with that class including other div's, some representing my "bands", and others just using the container class. Thus, my relevant CSS is:

div.band {
  width: 100% !important;
  background-color: #D7EAD8;
  color: #323F3F;
}

and my HTML:

<div class="container-fluid">
  <div class="row band">Hello band</div>
  <div class="container">
    <div class="row">...</div>
  </div>
  <div class="row band">Another band</div>
  <div class="container">
  <div class="row">...</div>
  </div>
</div>

Yet, this does not fully work as I keep getting some white margin at the right edge of the "band" div. I don't know Bootstrap internals and surely I'm doing something wrong, could anyone suggest a solution to make the "band" full-width?

like image 353
Naftis Avatar asked Dec 11 '22 18:12

Naftis


1 Answers

In these cases, I set up the page containers in a per-block manner like this:

div.band {
  background-color: #D7EAD8;
  color: #323F3F;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<div class="band">
  <div class="container-fluid">
    <div class="row">
      <div class="col-sm-12">
        Column content here
      </div>
    </div>
  </div>
</div>
<div class="container-fluid">
    <div class="row">
      <div class="col-sm-12">
        Regular usage of Bootstrap
      </div>
    </div>
  </div>

You don't need the width on .band in this way.

like image 130
Karl Dawson Avatar answered Dec 28 '22 00:12

Karl Dawson