Bootstrap 5 Grid: Small Devices

Small device grid example

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 two-column layout. For small devices, we want to split the columns 25% / 75%.

Small devices are defined as screen widthFrom 576 pixels to 767 pixels.

For small devices, we will use .col-sm-* Class.

We add the following classes to the two columns:

<div class="col-sm-3">....</div>
<div class="col-sm-9">....</div>

The following example will produce a 25% / 75% split on small (as well as medium, large, extra-large, and extra-extra-large) devices. On extra-small devices, it will automatically stack (100%):

Example

<div class="container-fluid">
  <div class="row">
    <div class="col-sm-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-sm-9 bg-dark">
      <p>In 1980, WWF officially came to China and was invited by the Chinese government to carry out the protection work of giant pandas and their habitats...</p>
    </div>
  </div>
</div>

Try It Yourself

Note:Ensure the total is equal to or less than 12 (not all 12 available columns are required):

For a 33.3% / 66.6% split, you should use .col-sm-4 and .col-sm-8For a 50% / 50% split, you should use .col-sm-6 and .col-sm-6):

Example

<!-- 33.3/66.6% split: -->
<div class="container-fluid">
  <div class="row">
    <div class="col-sm-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-sm-8 bg-dark">
      <p>In 1980, WWF officially came to China and was 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-sm-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-sm-6 bg-dark">
      <p>In 1980, WWF officially came to China and was invited by the Chinese government to carry out the protection work of giant pandas and their habitats...</p>
    </div>
  </div>
</div>

Try It Yourself

Automatic Layout Columns

In Bootstrap 5, there is a simple way to create equal-width columns for all devices: just from .col-sm-* remove numbers, and only col elementsis used .col-sm class. Bootstrap will recognize how many columns there are, and each column will receive the same width.

If the screen sizeLess than 576px, columns will be stacked horizontally:

<!-- Two columns: 50% width on all screens, except extra small devices (100% width) -->
<div class="row">
  <div class="col-sm">1 of 2</div>
  <div class="col-sm">2 of 2</div>
</div>
<!-- Four columns: 25% width on all screens, except extra small devices (100% width) -->
<div class="row">
  <div class="col-sm">1 of 4</div>
  <div class="col-sm">2 of 4</div>
  <div class="col-sm">3 of 4</div>
  <div class="col-sm">4 of 4</div>
</div>

Try It Yourself

The next chapter will show how to add different split percentages for medium-sized devices.