Bootstrap 5 Grid: Extra Small Devices
- Previous Page BS5 Stacking/Horizontal
- Next Page BS5 Grid Small
Extra Small Device Grid Instance
XSmall | Small | Medium | Large | Extra Large | XXL | |
---|---|---|---|---|---|---|
Class prefix | .col- |
.col-sm- |
.col-md- |
.col-lg- |
.col-xl- |
.col-xxl- |
Screen width | <576px | >=576px | >=768px | >=992px | >=1200px | >=1400px |
Assuming we have a simple layout with two columns. We want the columns to beAllDevice split 25% / 75%.
We add the following classes to both columns:
<div class="col-3">....</div> <div class="col-9">....</div>
The following example will result in a 25% / 75% split for all devices (extra small, small, medium, large, extra large, and extra extra large):
Example
<div class="container-fluid"> <div class="row"> <div class="col-3 bg-primary"> <p>The World Wide Fund for Nature (WWF), founded on April 29, 1961, has a giant panda as its logo...</p> </div> <div class="col-9 bg-dark"> <p>In 1980, WWF officially came to China, invited by the Chinese government to carry out the protection work of giant pandas and their habitats...</p> </div> </div> </div>
Note:Please ensure the total is equal to or less than 12 (not all 12 available columns need to be used):
For 33.3% / 66.6% split, you should use .col-4
and .col-8
(For 50% / 50% split, you should use .col-6
and .col-6
):
Example
<!-- 33.3%/66.6% split --> <div class="container-fluid"> <div class="row"> <div class="col-4 bg-primary"> <p>The World Wide Fund for Nature (WWF), founded on April 29, 1961, has a giant panda as its logo...</p> </div> <div class="col-8 bg-dark"> <p>In 1980, WWF officially came to China, invited by the Chinese government to carry out the protection work of giant pandas and their habitats...</p> </div> </div> </div> <!-- 50%/50% split --> <div class="container-fluid"> <div class="row"> <div class="col-6 bg-primary"> <p>The World Wide Fund for Nature (WWF), founded on April 29, 1961, has a giant panda as its logo...</p> </div> <div class="col-6 bg-dark"> <p>In 1980, WWF officially came to China, invited by the Chinese government to carry out the protection work of giant pandas and their habitats...</p> </div> </div> </div>
Automatic Layout Columns
In Bootstrap 5, there is a simple way to create automatic layout columns for all devicesequally wide columns: Just from .col-*
Remove the numbers and use only on the col element .col
Class. Bootstrap will recognize how many columns there are, and each column will receive the same width:
<!-- Two columns: 50% width --> <div class="row"> <div class="col">1 of 2</div> <div class="col">2 of 2</div> </div> <!-- Four columns: 25% width --> <div class="row"> <div class="col">1 of 4</div> <div class="col">2 of 4</div> <div class="col">3 of 4</div> <div class="col">4 of 4</div> </div>
The next chapter will show how to add different split percentages for small devices.
- Previous Page BS5 Stacking/Horizontal
- Next Page BS5 Grid Small