Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to space vertically stacked buttons in Bootstrap 3

I want to have 3 buttons across a row in Bootstrap 3, but when it changes to the xs grid, stack them vertically. I'd like to introduce some spacing (margin) between the buttons - but only when the buttons are stacked vertically. Can I do this in LESS?

          <div class="row">
            <div class="col-sm-4 btn-vert-block">
              <span>
                <button type="button" class="btn btn-primary btn-block">Go Back</button>
              </span>
            </div>
            <div class="col-sm-4 btn-vert-block">
              <span>
                <button type="button" class="btn btn-primary btn-block center-block">Preview</button>
              </span>
            </div>
            <div class="col-sm-4 btn-vert-block">
              <span class="">
                <button type="button" class="btn btn-success pull-right btn-block">Go Next</button>
              </span>
            </div>
          </div>
like image 210
JPMox Avatar asked Jan 12 '23 08:01

JPMox


1 Answers

It is not neccessary to involve LESS.

You can use this code, for applying margins to .btn-vert-block below 767px width (or any other):

@media (max-width: 767px) {
    .btn-vert-block + .btn-vert-block {
        margin-top: 10px;    
    }    
}

Demo Fiddle

like image 178
Tigran Petrossian Avatar answered Jan 19 '23 10:01

Tigran Petrossian