In the Bootstrap 3 framework, it is important to specify a number after sm
when using column classes. For example, instead of just col-sm
, you should use col-sm-3
. If no number is provided, the entire row will default to col-sm-12
.
Check out the documentation here.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container-fluid">
<div class="row">
<div class="col-sm" style="background-color:lavender;">.col-sm</div>
<div class="col-sm" style="background-color:lavenderblush;">.col-sm-</div>
<div class="col-sm" style="background-color:lavender;">.col-sm</div>
</div>
</div>
For Bootstrap 4, the number "4" should be used with col-sm
classes instead.
View the Bootstrap 4 documentation for more information.
Thanks to flexbox, grid columns without a specified width will automatically layout as equal width columns in Bootstrap 4. For example, four instances of .col-sm will each automatically be 25%
wide from the small breakpoint and up. See the
auto-layout columns section for more examples.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<div class="container-fluid">
<div class="row">
<div class="col-sm" style="background-color:lavender;">.col-sm-4</div>
<div class="col-sm" style="background-color:lavenderblush;">.col-sm-4</div>
<div class="col-sm" style="background-color:lavender;">.col-sm-4</div>
</div>
</div>
Differences between Bootstrap 4 Grid and Bootstrap 3:
Bootstrap 4
https://i.sstatic.net/aGGmT.png
Bootstrap 3
https://i.sstatic.net/DhKzr.png