Bootstrap 5 Grid: Large Devices

Course recommendation:

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 >=768px >=992px >=1200px >=1400px

In the previous chapter, we demonstrated a grid instance with classes suitable for small and medium devices. We used two divs (columns) and split 25%/75% on small devices, 50%/50% on medium devices:

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

But a 33% / 66% split design may be better on large devices.

Large devices are defined as screen widthFrom 992 pixels to 1199 pixels.

For large devices, we will use .col-lg-* Class:

<div class="col-sm-3 col-md-6 col-lg-4">....</div>
<div class="col-sm-9 col-md-6 col-lg-8">....</div>

On small devices, please use classes containing -sm- class. On medium devices, please use classes containing -md- class. On large devices, please use classes containing -lg- class.

The following example will split 25%/75% on small devices, 50%/50% on medium devices, and 33%/66% on large, 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">
      <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">
      <p>In 1980, WWF officially came to China, at the invitation of the Chinese government to carry out the protection of giant pandas and their habitats ...</p>
    </div>
  </div>
</div>

Try It Yourself

Note:Make sure the total is equal to or less than 12 (you do not need to use all 12 available columns):

only use Large

In the following example, we only specify .col-lg-6 class (without .col-md-* and/or .col-sm-*). This means that large, xlarge, and xxlarge devices will split 50%/50%. However, for medium, small, and extra small devices, it will be vertically stacked (100% width):

Example

<div class="container-fluid">
  <div class="row">
    <div class="col-lg-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-lg-6">
      <p>In 1980, WWF officially came to China, at the invitation of the Chinese government to carry out the protection 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-lg-* Remove the numbers and use only on the col element .col-lg class. Bootstrap will recognize how many columns there are, and each column will receive the same width.

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

<!-- Two columns: at large and above devices are 50% width -->
<div class="row">
  <div class="col-lg">1 of 2</div>
  <div class="col-lg">2 of 2</div>
</div>
<!-- Four columns: at large and above devices are 25% width -->
<div class="row">
  <div class="col-lg">1 of 4</div>
  <div class="col-lg">2 of 4</div>
  <div class="col-lg">3 of 4</div>
  <div class="col-lg">4 of 4</div>
</div>

Try It Yourself