Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is there no vertical space between Bootstrap 4 rows

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> 
like image 954
Martijn Harmenzon Avatar asked Sep 27 '17 16:09

Martijn Harmenzon


People also ask

How do I add a space between bootstrap rows?

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

How do you put a space between columns in bootstrap 4?

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...

How can I add vertical space between two divs in bootstrap?

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.

How do I set margins in bootstrap 4?

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.


1 Answers

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.

  • use g-0 for no gutters
  • use g-(1-5) to adjust horizontal & vertical gutters via spacing units
  • use gy-* to adjust vertical gutters
  • use gx-* to adjust horizontal gutters

Bootstrap 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.

like image 52
Zim Avatar answered Sep 18 '22 12:09

Zim