Arnold Zahrneinder
Arnold Zahrneinder

Reputation: 5200

Centering columns which are not multiple of 2

The offset cannot be of any use for centering columns which aren't multiples of 2 such as col-md-3. But let's say one needs to have a single one of such columns that also has to be centered, how can it be properly done with causing minimum impact on the bootstrap behavior?

I found that by using margins the bootstrap behavior gets messed up. (a backend developer asking this question, I'm not a UI expert)

Upvotes: 0

Views: 48

Answers (1)

Petr Blaha
Petr Blaha

Reputation: 64

HTML:

<div class="container">
  <div class="row">
    <div class="col-md-3 centercol" style="border:1px solid black;">
      This is in the middle.
    </div>
  </div>
</div>

CSS:

.centercol {
  margin:0 auto;
  float:none;
  }

See it in action: http://www.bootply.com/l7AArBXdlZ

Upvotes: 1

Related Questions