How to Customize Bootstrap Column Widths?

AnthonyGalli.com picture AnthonyGalli.com · Feb 26, 2015 · Viewed 85.6k times · Source

I have this, but I feel 4 is too big for my sidebar width and 3 is too small (it has to add up to 12).

  <div class="col-md-8">
  <div class="col-md-4">

I tried this but it doesn't work:

  <div class="col-md-8.5">
  <div class="col-md-3.5">

Is there another way to get a similar outcome?

Thanks for your help!

Answer

Tobia picture Tobia · Jul 10, 2015

To expand on @isherwood's answer, here is the complete code for creating custom -sm- widths in Bootstrap 3.3

In general you want to search for an existing column width (say col-sm-3) and copy over all the styles that apply to it, including generic ones, over to your custom stylesheet where you define new column widths.

.col-sm-3half, .col-sm-8half {
    position: relative;
    min-height: 1px;
    padding-right: 15px;
    padding-left: 15px;
}

@media (min-width: 768px) {
    .col-sm-3half, .col-sm-8half {
        float: left;
    }
    .col-sm-3half {
        width: 29.16666667%;
    }
    .col-sm-8half {
        width: 70.83333333%;
    }
}