Tuesday, September 2, 2014

Taming the Elusive 5 Column Bootstrap Layout

Twitter Bootstrap is one of the best things to happen to web development in recent years. Bootstrap 3 brought some awesome changes, but still there are troublesome areas. One the most common is setting up 5 column rows. Sure, you can build a custom compiled Bootstrap with a 20 column grid system or something, but most of us use vanilla Bootstrap. Thanks to SICC, we have a great solution for 5 column rows in Bootstrap 3. Simply add the following to a custom CSS file (no need to alter the Bootstrap CSS).

Core CSS

.col-xs-15,
.col-sm-15,
.col-md-15,
.col-lg-15 {
    position: relative;
    min-height: 1px;
    padding-right: 10px;
    padding-left: 10px;
}
.col-xs-15 {
    width: 20%;
    float: left;
}
@media (min-width: 768px) {
    .col-sm-15 {
        width: 20%;
        float: left;
    }
}
@media (min-width: 992px) {
    .col-md-15 {
        width: 20%;
        float: left;
    }
}
@media (min-width: 1200px) {
    .col-lg-15 {
        width: 20%;
        float: left;
    }
}


General Use

<div class="row">
    <div class="col-md-15">
    ...
    </div>
    <div class="col-md-15">
    ...
    </div>
    <div class="col-md-15">
    ...
    </div>
    <div class="col-md-15">
    ...
    </div>
    <div class="col-md-15">
    ...
    </div>
</div>