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.
<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>
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.
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)
If you need to separate rows in bootstrap, you can simply use . form-group . This adds 15px margin to the bottom of row.
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"> </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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With