Bootstrap 5 Grid: Extra Large Devices
- Previous Page BS5 Grid Large
- Next Page BS5 Grid XXL
Extra large 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 |
In the previous chapter, we demonstrated a grid instance that includes classes for small, medium, and large devices. We used two divs (columns) and split 25%/75% on small devices, 50%/50% on medium devices, and 33%/66% on large devices:
<div class="col-sm-3 col-md-6 col-lg-4">....</div> <div class="col-sm-9 col-md-6 col-lg-8">....</div>
But on xlarge devices, a 20% / 80% split design may be better.
Extra large devices are defined as screen widths of 1200 pixels and above.
For xlarge devices, we will use .col-xl-*
Class:
<div class="col-sm-3 col-md-6 col-lg-4 col-xl-2">....</div> <div class="col-sm-9 col-md-6 col-lg-8 col-xl-10">....</div>
The following example will split 25%/75% on small devices, 50%/50% on medium devices, 33%/66% on large devices, and 20%/80% on xlarge and xxlarge devices. On extra small devices, it will automatically stack (100%):
Example
<div class="container-fluid"> <div class="row"> <div class="col-sm-3 col-md-6 col-lg-4 col-xl-2"> <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-sm-9 col-md-6 col-lg-8 col-xl-10"> <p>In 1980, WWF officially came to China, invited by the Chinese government to carry out the protection work of the giant panda and its habitat...</p> </div> </div> </div>
Note:Make sure the total is always 12.
only use XLarge
In the following example, we only specify .col-xl-6
class (without .col-lg-*
,.col-md-*
and/or .col-sm-*
)。This means that xlarge and xxlarge devices will split 50%/50%. However, for large, medium, small, and extra-small devices, it will be vertically stacked (100% width):
Example
<div class="container-fluid"> <div class="row"> <div class="col-xl-6"> <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-xl-6"> <p>In 1980, WWF officially came to China, invited by the Chinese government to carry out the protection work of the giant panda and its habitat...</p> </div> </div> </div>
Automatic Layout Columns
In Bootstrap 5, there is a simple way to create equal-width columns for all devices: just from .col-xl-*
remove the numbers and use only on the col element .col-xl
class. Bootstrap will recognize how many columns there are, and each column will receive the same width.
If the screen sizeLess than 1200px, columns will be horizontally stacked:
<!-- Two columns: on extra-large and larger devices are 50% width --> <div class="row"> <div class="col-xl">1 of 2</div> <div class="col-xl">2 of 2</div> </div> <!-- Four columns: on extra-large and larger devices are 25% width --> <div class="row"> <div class="col-xl">1 of 4</div> <div class="col-xl">2 of 4</div> <div class="col-xl">3 of 4</div> <div class="col-xl">4 of 4</div> </div>
- Previous Page BS5 Grid Large
- Next Page BS5 Grid XXL