John Magnolia John Magnolia - 1 year ago 42
CSS Question

Bootstrap 3 grid with no gap

I am trying to create a 2 column grid, with literally a 50% with no margins or padding.

How do I achieve this with Bootstrap 3 I tried this but end up with negative margins at tablet/desktop break points:


<div class="container">
<div class="row">
<div class="col-sm-6 offset-0">Col 1</div>
<div class="col-sm-6 offset-0">Col 2</div>


.container {
background: green;
overflow: hidden;
.row > * {
background: blue;
color: #fff;
.row :first-child {
background: red;
.offset-0 {
padding-left: 0;
padding-right: 0;



The grid system in Bootstrap 3 requires a bit of a lateral shift in your thinking from Bootstrap 2. A column in BS2 (col-*) is NOT synonymous with a column in BS3 (col-sm-*, etc), but there is a way to achieve the same result.

Check out this update to your fiddle: (code copied below).

First of all, you don't need to specify a col for each screen size if you want 50/50 columns at all sizes. col-sm-6 applies not only to small screens, but also medium and large, meaning class="col-sm-6 col-md-6" is redundant (the benefit comes in if you want to change the column widths at different size screens, such as col-sm-6 col-md-8).

As for the margins issue, the negative margins provide a way to align blocks of text in a more flexible way than was possible in BS2. You'll notice in the jsfiddle, the text in the first column aligns visually with the text in the paragraph outside the row -- except at "xs" window sizes, where the columns aren't applied.

If you need behavior closer to what you had in BS2, where there is padding between each column and there are no visual negative margins, you will need to add an inner-div to each column. See the inner-content in my jsfiddle. Put something like this in each column, and they will behave the way old col-* elements did in BS2.

jsfiddle HTML

<div class="container">
    <p class="other-content">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse aliquam sed sem nec viverra. Phasellus fringilla metus vitae libero posuere mattis. Integer sit amet tincidunt felis. Maecenas et pharetra leo. Etiam venenatis purus et nibh laoreet blandit.</p>
    <div class="row">
        <div class="col-sm-6 my-column">
            Col 1
            <p class="inner-content">Inner content - THIS element is more synonymous with a Bootstrap 2 col-*.</p>
        <div class="col-sm-6 my-column">
            Col 2

and the CSS

.row {
    border: blue 1px solid;
.my-column {
    background-color: green;
    padding-top: 10px;
    padding-bottom: 10px;
.my-column:first-child {
    background-color: red;

.inner-content {
    background: #eee;
    border: #999;
    border-radius: 5px;
    padding: 15px;