Bootstrap 5 Grid basic


In Bootstrap 5, the grid system is a powerful layout tool based on a 12-column system, which helps create responsive layouts. Here’s a quick overview of how to use the grid system in Bootstrap 5:

column 1 column 1 column 1 column 1 column 1 column 1 column 1 column 1 column 1 column 1 column 1 column 1
 column 2  column 2  column 2  column 2  column 2  column 2
 column 3  column 3  column 3  column 3
 column 4  column 4  column 4
 column 5  column 2  column 5
column 6 column 6
column 4 column 8
column 12

Basic Structure of the Bootstrap Grid:

  • The Bootstrap grid system uses containers, rows, and columns to layout and align content.
  • A .container or .container-fluid element contains rows, and each row contains .col elements.
  • The .col class provides flexible column sizing that automatically distributes remaining space across columns.
Example
<div class="container-fluid">
<div class="row">
<div class="col" style="background:pink">Column 1</div>
<div class="col" style="background:gray">Column 2</div>
<div class="col" style="background:pink">Column 3</div>
</div>
</div>

Try it yourself

Column Custom Sizes:

  • The grid system uses a 12-column layout, so you can specify how many columns a div should span using .col-{breakpoint}-{number}.
  • For instance, .col-lg-4 will span 4 out of 12 columns on large screens and above.
Example
<div class="container-fluid">
<div class="row">
<div class="col-4" style="background:pink">4/12 Width</div>
<div class="col-8" style="background:gray">8/12 Width</div>
</div>
</div>

Try it yourself

Responsive Columns:

    Use .col-{breakpoint}-{number} to make columns responsive. For example, .col-md-6 makes the column take up half the row width on md screens and larger.

  • col-xs- (Extra small, <576px)
  • col-sm- (Small, ≥576px)
  • col-md- (Medium, ≥768px)
  • col-lg- (Large, ≥992px)
  • col-xl- (Extra large, ≥1200px)
  • col-xxl- (Extra extra large, ≥1400px)
Example
<div class="container-fluid">
<div class="row">
<div class="col-sm-12 col-md-6 col-lg-4" style="background:pink">Responsive Column</div>
<div class="col-sm-12 col-md-6 col-lg-4" style="background:green">Responsive Column</div>
<div class="col-sm-12 col-md-6 col-lg-4" style="background:pink">Responsive Column</div>
</div>
</div>

Try it yourself

Nesting Columns:

    You can nest rows and columns within columns for more complex layouts.

Example
<div class="row">
<div class="col-6" style="background:pink;padding:10px">
<div class="row">
<div class="col-6" style="background:blue">Nested Column</div>
<div class="col-6" style="background:red">Nested Column</div>
</div>
</div>
<div class="col-6" style="background:green;padding:10px">Main Column</div>
</div>

Try it yourself


Whereisstuff is simple learing platform for beginer to advance level to improve there skills in technologies.we will provide all material free of cost.you can write a code in runkit workspace and we provide some extrac features also, you agree to have read and accepted our terms of use, cookie and privacy policy.
© Copyright 2024 www.whereisstuff.com. All rights reserved. Developed by whereisstuff Tech.