Utilize breakpoint-specific column classes for easy column sizing without an explicit numbered class like .col-sm-6
.
For example, here are two grid layouts that apply to every device and viewport, from xs to xxl. Add any number of unit-less classes for each breakpoint you need and every column will be the same width.
Equal-width columns can be broken into multiple lines if you use <div class="w-100"></div>
in the point where you want to split the row.
Auto-layout for flexbox grid columns also means you can set the width of one column and have the sibling columns automatically resize around it. You may use predefined grid classes (as shown below) or inline widths. Note that the other columns will resize no matter the width of the center column.
Use col-{breakpoint}-auto
classes to size columns based on the natural width of their content.
<!-- Equal columns -->
<div class="container">
<div class="row">
<div class="col"> 1 of 2 </div>
<div class="col"> 2 of 2 </div>
</div>
<div class="row">
<div class="col"> 1 of 3 </div>
<div class="col"> 2 of 3 </div>
<div class="col"> 3 of 3 </div>
</div>
</div>
<!-- Equal-width columns can be broken into multiple lines with .w-100 -->
<div class="container">
<div class="row">
<div class="col">Column</div>
<div class="col">Column</div>
<div class="w-100"></div>
<div class="col">Column</div>
<div class="col">Column</div>
</div>
</div>
<!-- Setting one column width -->
<div class="container">
<div class="row">
<div class="col"> 1 of 3 </div>
<div class="col-6"> 2 of 3 (wider) </div>
<div class="col"> 3 of 3 </div>
</div>
<div class="row">
<div class="col"> 1 of 3 </div>
<div class="col-5"> 2 of 3 (wider) </div>
<div class="col"> 3 of 3 </div>
</div>
</div>
<!-- Variable width content -->
<div class="container">
<div class="row justify-content-md-center">
<div class="col col-lg-2"> 1 of 3 </div>
<div class="col-md-auto"> Variable width content </div>
<div class="col col-lg-2"> 3 of 3 </div>
</div>
<div class="row">
<div class="col"> 1 of 3 </div>
<div class="col-md-auto"> Variable width content </div>
<div class="col col-lg-2"> 3 of 3 </div>
</div>
</div>