Open In App

BootStrap 5 Layout Grid System

BootStrap5 Layout Grid system is responsive. It comes with a flexbox and allows up to 12 columns across the page. You can also group the columns together. The grid system is a powerful mobile-first responsive flexbox grid.

How it works: Here’s how the grid system comes together:



BootStrap5 Layout Grid System:

Example 1: Let’s see an example of auto-layout columns.






<!DOCTYPE html>
<html>
 
<head>
    <!--Bootstrap CDN -->
    <link rel="stylesheet"
          href=
          crossorigin="anonymous">
</head>
 
<body class="m-2">
    <h1 class="text-success"> GeeksforGeeks </h1>
    <h3>BootStrap5 Layout Grid system</h3>
 
    <section class="container">
        <section class="row">
            <section class="col border bg-success">
                GFG Column 1
            </section>
            <section class="col border bg-secondary">
                GFG Column 2
            </section>
            <section class="col border bg-danger">
                GFG Column 3
            </section>
        </section>
        <br>
        <section class="row">
            <section class="col border bg-warning">
                GFG Column 1
            </section>
            <section class="col-6 border bg-light">
                GFG Column 2
            </section>
            <section class="col border bg-info">
                GFG Column 3
            </section>
        </section>
    </section>
</body>
 
</html>

Output:

bootstrap 5 Layout Grid System

Example 2: Let us see an example of equal width.




<!DOCTYPE html>
<html>
 
<head>
    <!--Bootstrap CDN -->
    <link rel="stylesheet"
          href=
          crossorigin="anonymous">
</head>
 
<body class="m-2">
    <h1 class="text-success"> GeeksforGeeks </h1>
    <h3>BootStrap5 Layout Grid system</h3>
 
    <section class="container">
        <section class="row">
            <section class="col border
                bg-danger">
                GeeksforGeeks
            </section>
            <section class="col border
                bg-secondary">
                GeeksforGeeks
            </section>
            <section class="col border
                bg-primary">
                GeeksforGeeks
            </section>
            <section class="col border
                        bg-info">
                GeeksforGeeks
            </section>
            <section class="col border
                    bg-warning">
                GeeksforGeeks
            </section>
        </section>
        <br><br>
        <section class="row">
            <section class="col border
                    bg-secondary">
                GeeksforGeeks
            </section>
            <section class="col border
                    bg-success">
                GeeksforGeeks
            </section>
            <section class="col border
                    bg-danger">
                    GeeksforGeeks
            </section>
            <section class="col border
                    bg-primary">
                GeeksforGeeks
            </section>
        </section>
      </section>
</body>
 
</html>

Output:

bootstrap 5 Layout Grid System

Reference: https://getbootstrap.com/docs/5.0/layout/grid/


Article Tags :