I am trying to migrate from Bootstrap 3 to Bootstrap 4. Bootstrap 3 had vertical space between rows by default, but this is not the case in Bootstrap 4. Can someone please explain why? Or am I missing something in my HTML?
<div class="container-fluid"> <div class="row"> <div class="col-9"> <div class="row"> <div class="col"> <div class="card"> <div class="card-header"> Card01 </div> <div class="card-body"> Card01 </div> </div> </div> </div> <div class="row"> <div class="col"> <div class="card"> <div class="card-header"> Card02 </div> <div class="card-body"> Card02 </div> </div> </div> </div> </div> </div> </div>
If you need to separate rows in bootstrap, you can simply use . form-group . This adds 15px margin to the bottom of row.
Bootstrap 4 has spacing utilities that make adding (or substracting) the space (gutter) between columns easier. Extra CSS isn't necessary. You can adjust margins on the column contents using the margin utils such as ml-0 (margin-left:0), mr-0 (margin-right:0), mx-1 (. 25rem left & right margins), etc...
As for vertical spacing, unfortunately, there isn't anything set built-in like that in Bootstrap 3, so you will have to invent your own custom class to do that. I'd usually do something like . top-buffer { margin-top:20px; } . This does the trick, and obviously, it doesn't have to be 20px, it can be anything you like.
r - sets margin-right or padding-right. x - sets both padding-left and padding-right or margin-left and margin-right. y - sets both padding-top and padding-bottom or margin-top and margin-bottom. blank - sets a margin or padding on all 4 sides of the element.
Bootstrap 5 (update 2021)
Bootstrap 5 has new gutter classes that are specifically designed to adjust the gutter for an entire row. Additionally, there is now the concept of vertical gutters to adjust the vertical spacing between rows and columns that wrap inside each row.
g-0
for no guttersg-(1-5)
to adjust horizontal & vertical gutters via spacing unitsgy-*
to adjust vertical guttersgx-*
to adjust horizontal guttersBootstrap 4 (original answer)
Rows no longer have margin-bottom
in Bootstrap 4. Use the new spacing utils (mb-4
).
See https://stackoverflow.com/a/42960338/171456.
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