htmlcsstwitter-bootstrapgutter

Bootstrap 3 - reducing gutter size


What I want to achieve is:

http://i.imgur.com/CPb8vAu.png

While so far it looks like this (bottom margins aren't the issue, I decided that they should be smaller):

http://i.imgur.com/2SKqx0P.png

Unfortunately the gutter size is based on padding that is marked as the grey part in the image up. I would like each part to have the same size: 15 px.

The part of code I am referring to is (where groups-margin sets bottom margin for each button):

<div class="row">
                <div class="col-sm-6 groups-margin">
                    <a class="btn btn-primary btn-large btn-block outline" href="#">Grupa 1 <span class="group-stations-count">Stacje: 3</span></a>
                    <a class="btn btn-primary btn-large btn-block outline" href="#">Grupa 2 <span class="group-stations-count">Stacje: 1</span></a>
                    <a class="btn btn-primary btn-large btn-block outline" href="#">Grupa 3 <span class="group-stations-count">Stacje: 3</span></a>
                    <a class="btn btn-primary btn-large btn-block outline" href="#">Grupa 4 <span class="group-stations-count">Stacje: 6</span></a>
                </div>
                <div class="col-sm-6 groups-margin">
                    <a class="btn btn-primary btn-large btn-block outline" href="#">Grupa 5 <span class="group-stations-count">Stacje: 4</span></a>
                    <a class="btn btn-primary btn-large btn-block outline" href="#">Grupa 6 <span class="group-stations-count">Stacje: 6</span></a>
                    <a class="btn btn-primary btn-large btn-block outline" href="#">Grupa 7 <span class="group-stations-count">Stacje: 7</span></a>
                    <a class="btn btn-primary btn-large btn-block outline" href="#">Grupa 8 <span class="group-stations-count">Stacje: 2</span></a>
                </div>
            </div>

Solution

  • Wrap your col-sm-6 with a div, say .input-row like this:

    <div class="row">
        <div class="input-row">
                    <div class="col-sm-6 groups-margin">
                            <a class="btn btn-primary btn-large btn-block outline" href="#">Grupa 1 <span class="group-stations-count">Stacje: 3</span></a>
                            <a class="btn btn-primary btn-large btn-block outline" href="#">Grupa 2 <span class="group-stations-count">Stacje: 1</span></a>
                            <a class="btn btn-primary btn-large btn-block outline" href="#">Grupa 3 <span class="group-stations-count">Stacje: 3</span></a>
                            <a class="btn btn-primary btn-large btn-block outline" href="#">Grupa 4 <span class="group-stations-count">Stacje: 6</span></a>
                    </div>
                    <div class="col-sm-6 groups-margin">
                            <a class="btn btn-primary btn-large btn-block outline" href="#">Grupa 5 <span class="group-stations-count">Stacje: 4</span></a>
                            <a class="btn btn-primary btn-large btn-block outline" href="#">Grupa 6 <span class="group-stations-count">Stacje: 6</span></a>
                            <a class="btn btn-primary btn-large btn-block outline" href="#">Grupa 7 <span class="group-stations-count">Stacje: 7</span></a>
                            <a class="btn btn-primary btn-large btn-block outline" href="#">Grupa 8 <span class="group-stations-count">Stacje: 2</span></a>
                    </div>
        </div>
    </div>
    

    Now since you're using col-sm-, add these properties within a media query like this:

    @media (min-width: 768px){
        .input-row .col-sm-6:first-child{padding-right:7.5px;}
        .input-row .col-sm-6:last-child{padding-left:7.5px;}
    }
    

    Now all gutters (left, right and middle will be 15px)


    Here's a jsfiddle with the above codes: http://jsfiddle.net/AndrewL32/65sf2f66/47/