Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vertical space when stacking columns in Bootstrap 3

When columns are stacked in mobile mode, I would like some vertical space separating the column contents, how can I do this?

See jsfiddle in http://jsfiddle.net/tofutim/3sWEN/ and vary the width of the output. There should be some spacing before the second lorem ipsum.

enter image description here

<div class="container">     <div class="well well-lg" style="margin:10px">     <div class="row">         <div class="col-sm-6">             <p>"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."</p>             <form>                                <input type="textbox" class="form-control" placeholder="Username"></input>                 <input type="password" class="form-control" placeholder="Password"></input>                                  </form>         </div>         <div class="col-sm-6">             <p>"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."</p>             <form role="form">                 <div class="form-group">                       <button class="form-control btn btn-default">Push me</button>                 <input type="textbox" class="form-control" placeholder="Username"></input>                 <input type="password" class="form-control" placeholder="Password"></input>                             </div>             </form>         </div>     </div>     </div> </div> 
like image 395
tofutim Avatar asked Nov 06 '13 20:11

tofutim


People also ask

How do you put a space between two columns in Bootstrap?

To add space between columns in Bootstrap use gutter classes. With gutters you can add horizontal or vertical space or even specify how big space should be on different screen size.

What is Col MD 6 in Bootstrap?

col- (extra small devices - screen width less than 576px) . col-sm- (small devices - screen width equal to or greater than 576px) . col-md- (medium devices - screen width equal to or greater than 768px)

How do you put a space between two rows in Bootstrap?

If you need to separate rows in bootstrap, you can simply use . form-group . This adds 15px margin to the bottom of row.


1 Answers

One way would be with CSS that adds margin-bottom to col-* on smaller devices/widths..

@media (max-width: 768px) {    [class*="col-"] {       margin-bottom: 15px;   }  } 

Another way is to add a div that is only visible on smaller devices/widths..

 <div class="col-sm-6">     <div class="hidden-lg hidden-md hidden-sm">&nbsp;</div>         ... 

Demo: http://bootply.com/92276


Update 2019

Bootstrap 4 now has spacing utilities that can be used.

Also see: Add spacing between vertically stacked columns in Bootstrap 4

like image 187
Zim Avatar answered Oct 15 '22 01:10

Zim