Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 3: Missing gutters

Just started playing around with bootstrap 3 and I can't get gutters between columns to work.

I created the most basic code to test with:

<!DOCTYPE html> <html lang="en"> <head>     <title>Test</title>     <script src="http://code.jquery.com/jquery.js"></script>     <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/js/bootstrap.min.js">                                                                                                                                  </script>     <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/css/bootstrap.min.css" rel="stylesheet" media="screen" />     <style>         .box1 {             background-color: green;         }         .box2 {             background-color: blue;         }     </style> </head> <div class="container">     <div class="row">         <div class="col-lg-4 box1">             <h1>Test</h1>         </div>         <div class="col-lg-8 box2">             <h1>Test2</h1>         </div>     </div> </div> </html> 

And the result is just one big green/blue box without any gutter in between the two columns. I have also tried it on a fiddle with no luck http://jsfiddle.net/Tgkkb/ What am I missing?

like image 830
bcoop713 Avatar asked Aug 06 '13 02:08

bcoop713


People also ask

What is row no gutters?

Use the .row-no-gutters class to remove the gutters from a row and its columns: .col-sm-4.

What is gutters in Bootstrap?

Gutters in Bootstrap 5 gx-0 to gx-5 for the horizontal gutter widths, gy-0 to gy-5 for the vertical gutters or g-0 to g-5 for vertical and horizontal gutters. For example, in the following Bootstrap grid, gutters are set to g-1 : <div class="row g-1"> <div class="col-4"> <div class="col-content"></div>

Which class will give vertical gutters in Bootstrap grid system?

Change horizontal gutters with . gx-* classes, vertical gutters with . gy-* , or all gutters with . g-* classes. .


1 Answers

Bootstrap 3 switched to using padding for the gutters rather than margins. So, the content is parted, but the boxes aren't. And a background-color will fill the padding as well.

Though, you should be able to get the desired effect by setting the background on inner boxes:

<div class="row">     <div class="col-sm-4">         <div class="box1">             <h1>Test</h1>         </div>     </div>     <div class="col-sm-8">         <div class="box2">             <h1>Test2</h1>         </div>     </div> </div> 

http://jsfiddle.net/PFxUk/


Though, the goal is just to apply the background to a single, wrapping child. So, if the headers definitely won't have any siblings, then you can possibly forgo the additional <div>s:

<div class="row">     <div class="col-sm-4">         <h1 class="box1">Test</h1>     </div>     <div class="col-sm-8">         <h1 class="box2">Test2</h1>     </div> </div> 

http://jsfiddle.net/G2gbG/

like image 111
Jonathan Lonowski Avatar answered Oct 08 '22 14:10

Jonathan Lonowski