S
S
setevoi112016-01-10 01:37:26
css
setevoi11, 2016-01-10 01:37:26

Bootstrap 3 center align blocks?

How to center align blocks to resolve col-sm col-xs ?
now aligned .block1 left .block2 center .block3 right

<div class="container">
       <div class="row padded">
          <div class="col-lg-2 col-md-3 col-sm-12 col-xs-12">
            <div class="block1">лого</div>
          </div>
          <div class="col-lg-8 col-md-6 col-sm-12 col-xs-12">
            <div class="block2">поиск</div>
          </div>
          <div class="col-lg-2 col-md-3 col-sm-12 col-xs-12">
            <div class="block3">корзина</div>
          </div>                    
    </div>

Answer the question

In order to leave comments, you need to log in

5 answer(s)
D
Dmitry Evgrafovich, 2016-01-10
@setevoi11

Blocks or block content? there is a .text-center class for the content. Block by block, they gave you the answer

S
setevoi11, 2016-01-10
@setevoi11

so far so it turned out
can there be other options?

@media screen and (max-width: 768px) {
  .col-center-xs {
    text-align: center!important;
  }
}

L
lynnikvadim, 2016-03-12
@lynnikvadim

getbootstrap.com/css/#helper-classes-center

A
Anton, 2016-01-10
@hummingbird

There is also col-offset
Read the official documentation.
getbootstrap.com/css/#grid-offsetting

<div class="row">
  <div class="col-sm-5 col-md-6">.col-sm-5 .col-md-6</div>
  <div class="col-sm-5 col-sm-offset-2 col-md-6 col-md-offset-0">.col-sm-5 .col-sm-offset-2 .col-md-6 .col-md-offset-0</div>
</div>

<div class="row">
  <div class="col-sm-6 col-md-5 col-lg-6">.col-sm-6 .col-md-5 .col-lg-6</div>
  <div class="col-sm-6 col-md-5 col-md-offset-2 col-lg-6 col-lg-offset-0">.col-sm-6 .col-md-5 .col-md-offset-2 .col-lg-6 .col-lg-offset-0</div>
</div>

H
HellishGuardian, 2020-07-16
@HellishGuardian

Just add display: inline-block + float: none to the block. It worked for me.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question