Lesson 50 of 60 – Bootstrap Grid Practical Project
83%

Bootstrap Grid Practical Project

In this practical project, we will build a responsive course website section using the Bootstrap Grid System. You will learn how to combine containers, rows, columns, cards, spacing utilities, responsive breakpoints, buttons, and Flexbox.

Project Goal: Create a responsive course listing page that displays one column on small screens, two columns on medium screens, and three columns on large screens.

1. Project Overview

Our project will contain a simple course listing section. Each course will be displayed inside a Bootstrap card.

The project will demonstrate:

  • Bootstrap container.
  • Bootstrap rows.
  • Responsive columns.
  • Cards.
  • Buttons.
  • Spacing utilities.
  • Responsive breakpoints.
  • Flexbox.

2. Create the HTML Structure

Start with a basic HTML document.

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta
    name="viewport"
    content="width=device-width,
    initial-scale=1.0">

    <title>
        Bootstrap Grid Project
    </title>

</head>

<body>

    Content goes here.

</body>

</html>

The viewport meta tag is important for responsive layouts.

3. Add Bootstrap CSS

Include Bootstrap CSS inside the <head> section.

<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
rel="stylesheet">

This allows us to use Bootstrap's grid system and utility classes.

4. Create a Container

The Bootstrap container class provides a responsive fixed-width container.

<div class="container">

    Project Content

</div>

The container keeps the content organized and provides responsive horizontal spacing.

5. Add a Row

Inside the container, create a Bootstrap row.

<div class="container">

    <div class="row">

        Content

    </div>

</div>

The row acts as the main horizontal structure for the columns.

6. Create the First Column

Create a column using Bootstrap's grid class.

<div class="col-md-6">

    First Column

</div>

col-md-6 means the column takes 6 of the 12 grid columns from the medium breakpoint and above.

7. Create the Second Column

Add another column.

<div class="row">

    <div class="col-md-6">

        Column One

    </div>


    <div class="col-md-6">

        Column Two

    </div>

</div>

The two columns occupy half of the row each from the medium breakpoint and above.

8. Create Three Responsive Columns

For a three-column layout on large screens, use col-lg-4.

<div class="row">

    <div class="col-lg-4">
        Column One
    </div>

    <div class="col-lg-4">
        Column Two
    </div>

    <div class="col-lg-4">
        Column Three
    </div>

</div>

Each column takes 4 of the 12 grid columns, resulting in three equal columns.

9. Make the Project Mobile-Friendly

Use col-12 as the default and add larger breakpoint classes.

<div
class="col-12
col-md-6
col-lg-4">

    Course Card

</div>

This means:

  • Full width on small screens.
  • Half width from the medium breakpoint.
  • One-third width from the large breakpoint.

10. Add Grid Spacing

Use the g-4 class to add a gap between grid items.

<div class="row g-4">

    <div class="col-12 col-md-6 col-lg-4">
        Course
    </div>

    <div class="col-12 col-md-6 col-lg-4">
        Course
    </div>

</div>

The g-4 utility applies spacing between the grid columns and rows.

11. Create a Course Card

Now create the first course card.

<div class="card">

    <div class="card-body">

        <h3 class="card-title">
            HTML
        </h3>

        <p class="card-text">
            Learn HTML from beginner level.
        </p>

        <button class="btn btn-primary">
            Start Course
        </button>

    </div>

</div>

12. Add a Course Badge

Use a Bootstrap badge to display the course level.

<span
class="badge
bg-primary
rounded-pill">

    Beginner

</span>

Badges are useful for labels such as Beginner, Intermediate, Advanced, New, or Popular.

13. Add Course Duration

Add course information inside the card.

<p>

    <i class="bi bi-clock"></i>

    Duration: 2 Months

</p>

You can also use plain text if Bootstrap Icons are not included.

14. Create the CSS-Free Layout

One advantage of Bootstrap is that many layouts can be created without writing custom CSS.

<div class="container py-5">

    <div class="row g-4">

        <div class="col-12 col-md-6 col-lg-4">

            <div class="card h-100">

                <div class="card-body">

                    Course Content

                </div>

            </div>

        </div>

    </div>

</div>

15. Use h-100 for Equal Card Height

The h-100 utility can make cards fill the available height of their grid columns.

<div
class="card h-100">

    <div class="card-body">

        Course Content

    </div>

</div>

This is useful when cards in the same row contain different amounts of text.

16. Add Multiple Courses

Create multiple course cards inside the same row.

<div class="row g-4">


    <div class="col-12 col-md-6 col-lg-4">

        <div class="card h-100">

            <div class="card-body">

                <h3>HTML</h3>

            </div>

        </div>

    </div>


    <div class="col-12 col-md-6 col-lg-4">

        <div class="card h-100">

            <div class="card-body">

                <h3>CSS</h3>

            </div>

        </div>

    </div>


    <div class="col-12 col-md-6 col-lg-4">

        <div class="card h-100">

            <div class="card-body">

                <h3>JavaScript</h3>

            </div>

        </div>

    </div>


</div>

17. Add a Section Heading

Add a heading before the course grid.

<div class="text-center mb-5">

    <h1>
        Our Courses
    </h1>

    <p>
        Learn practical skills step by step.
    </p>

</div>

The text-center class centers the heading, while mb-5 adds bottom margin.

18. Add Course Buttons

Add a button to each course card.

<button
class="btn btn-primary
w-100">

    Start Course

</button>

The w-100 class makes the button fill the available width of the card body.

19. Add Course Price

A course card can also display its price.

<h4 class="text-success">

    ₹5,000

</h4>

<p class="text-body-secondary">

    One-time fee

</p>

Bootstrap text utilities can be used to visually organize the price and supporting information.

20. Add Course Features

Use a list to display course features.

<ul class="list-unstyled">

    <li>
        ✓ Practical Projects
    </li>

    <li>
        ✓ Assignments
    </li>

    <li>
        ✓ Certificate
    </li>

</ul>

The list-unstyled class removes the default list styling.

21. Add More Grid Items

Bootstrap automatically moves columns to the next row when there is not enough horizontal space.

<div class="row g-4">

    <div class="col-12 col-md-6 col-lg-4">
        HTML
    </div>

    <div class="col-12 col-md-6 col-lg-4">
        CSS
    </div>

    <div class="col-12 col-md-6 col-lg-4">
        JavaScript
    </div>

    <div class="col-12 col-md-6 col-lg-4">
        Bootstrap
    </div>

    <div class="col-12 col-md-6 col-lg-4">
        React
    </div>

    <div class="col-12 col-md-6 col-lg-4">
        Python
    </div>

</div>

22. Add a Responsive Header

Create a responsive header using Flexbox utilities.

<header
class="py-4
border-bottom
mb-5">


    <div
    class="d-flex
    flex-column
    flex-md-row
    justify-content-between
    align-items-center
    gap-3">


        <h2 class="mb-0">

            Soopro Pathshala

        </h2>


        <button
        class="btn btn-primary">

            Join Now

        </button>


    </div>


</header>

23. Add Responsive Alignment

The heading can be centered on small screens and aligned to the start on larger screens.

<div
class="text-center
text-md-start">

    <h1>
        Our Courses
    </h1>

</div>

This is another example of Bootstrap's mobile-first responsive utilities.

24. Complete Grid Structure

At this point, our main grid structure looks like this:

<div class="container py-5">


    <div
    class="text-center mb-5">

        <h1>
            Our Courses
        </h1>

        <p>
            Learn practical skills.
        </p>

    </div>


    <div class="row g-4">


        <div
        class="col-12
        col-md-6
        col-lg-4">

            Course Card

        </div>


        <div
        class="col-12
        col-md-6
        col-lg-4">

            Course Card

        </div>


        <div
        class="col-12
        col-md-6
        col-lg-4">

            Course Card

        </div>


    </div>


</div>

25. Test the Grid on Mobile

On a small screen, each course column uses the full width.

col-12

Therefore, the cards appear one below another.

Result: The layout automatically becomes mobile-friendly without writing custom media queries.

26. Test the Grid on Medium Screens

At the medium breakpoint, each card uses 6 columns.

col-md-6

Since the Bootstrap grid contains 12 columns, two cards can fit in one row.

6 + 6 = 12

27. Test the Grid on Large Screens

At the large breakpoint, each card uses 4 columns.

col-lg-4

Three cards can therefore fit in one row.

4 + 4 + 4 = 12

28. Complete Course Card

Here is a complete course card that we can use in our project.

<div class="card h-100 shadow-sm">


    <div class="card-body d-flex flex-column">


        <span
        class="badge
        bg-primary
        rounded-pill
        align-self-start
        mb-3">

            Beginner

        </span>


        <h3 class="card-title">

            HTML

        </h3>


        <p class="card-text">

            Learn HTML from
            beginner to practical
            level.

        </p>


        <h4 class="text-success">

            ₹5,000

        </h4>


        <ul class="list-unstyled">

            <li>
                ✓ Practical Projects
            </li>

            <li>
                ✓ Assignments
            </li>

            <li>
                ✓ Certificate
            </li>

        </ul>


        <button
        class="btn btn-primary
        w-100 mt-auto">

            Start Course

        </button>


    </div>


</div>

29. Complete Project Code

Now combine everything into one responsive Bootstrap Grid project.

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta
    name="viewport"
    content="width=device-width,
    initial-scale=1.0">

    <title>
        Bootstrap Course Project
    </title>


    <link
    href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
    rel="stylesheet">

</head>


<body>


<header
class="py-4 border-bottom">


    <div
    class="container">


        <div
        class="d-flex
        flex-column
        flex-md-row
        justify-content-between
        align-items-center
        gap-3">


            <h2 class="mb-0">

                Soopro Pathshala

            </h2>


            <button
            class="btn btn-primary">

                Join Now

            </button>


        </div>


    </div>


</header>


<main class="py-5">


    <div class="container">


        <div
        class="text-center mb-5">


            <h1>

                Our Courses

            </h1>


            <p>

                Learn practical
                skills step by step.

            </p>


        </div>


        <div class="row g-4">


            <div
            class="col-12
            col-md-6
            col-lg-4">


                <div
                class="card
                h-100
                shadow-sm">


                    <div
                    class="card-body
                    d-flex
                    flex-column">


                        <span
                        class="badge
                        bg-primary
                        rounded-pill
                        align-self-start
                        mb-3">

                            Beginner

                        </span>


                        <h3>
                            HTML
                        </h3>


                        <p>

                            Learn HTML
                            from beginner
                            to practical
                            level.

                        </p>


                        <h4
                        class="text-success">

                            ₹5,000

                        </h4>


                        <ul
                        class="list-unstyled">

                            <li>
                                ✓ Projects
                            </li>

                            <li>
                                ✓ Assignments
                            </li>

                            <li>
                                ✓ Certificate
                            </li>

                        </ul>


                        <button
                        class="btn
                        btn-primary
                        w-100
                        mt-auto">

                            Start Course

                        </button>


                    </div>


                </div>


            </div>


            <div
            class="col-12
            col-md-6
            col-lg-4">


                <div
                class="card
                h-100
                shadow-sm">


                    <div
                    class="card-body
                    d-flex
                    flex-column">


                        <span
                        class="badge
                        bg-success
                        rounded-pill
                        align-self-start
                        mb-3">

                            Intermediate

                        </span>


                        <h3>
                            CSS
                        </h3>


                        <p>

                            Learn CSS
                            and create
                            beautiful
                            web pages.

                        </p>


                        <h4
                        class="text-success">

                            ₹5,000

                        </h4>


                        <ul
                        class="list-unstyled">

                            <li>
                                ✓ Projects
                            </li>

                            <li>
                                ✓ Assignments
                            </li>

                            <li>
                                ✓ Certificate
                            </li>

                        </ul>


                        <button
                        class="btn
                        btn-success
                        w-100
                        mt-auto">

                            Start Course

                        </button>


                    </div>


                </div>


            </div>


            <div
            class="col-12
            col-md-6
            col-lg-4">


                <div
                class="card
                h-100
                shadow-sm">


                    <div
                    class="card-body
                    d-flex
                    flex-column">


                        <span
                        class="badge
                        bg-info
                        rounded-pill
                        align-self-start
                        mb-3">

                            Advanced

                        </span>


                        <h3>
                            Bootstrap
                        </h3>


                        <p>

                            Build responsive
                            websites with
                            Bootstrap.

                        </p>


                        <h4
                        class="text-success">

                            ₹5,000

                        </h4>


                        <ul
                        class="list-unstyled">

                            <li>
                                ✓ Projects
                            </li>

                            <li>
                                ✓ Assignments
                            </li>

                            <li>
                                ✓ Certificate
                            </li>

                        </ul>


                        <button
                        class="btn
                        btn-info
                        w-100
                        mt-auto">

                            Start Course

                        </button>


                    </div>


                </div>


            </div>


        </div>


    </div>


</main>


</body>

</html>

30. Final Project Result

After completing the project, the page will have a responsive course layout.

  • On small screens: one course card per row.
  • On medium screens: two course cards per row.
  • On large screens: three course cards per row.
  • Cards have equal height using h-100.
  • Cards have spacing using g-4.
  • Buttons use Bootstrap button classes.
  • Course labels use Bootstrap badges.
  • The layout uses Bootstrap's responsive grid.
  • No custom media queries are required for this basic layout.
Project Complete! You have created a responsive Bootstrap course grid using containers, rows, columns, cards, spacing, Flexbox, and responsive breakpoints.

📌 Key Points

  • The Bootstrap grid uses 12 columns.
  • container provides a responsive content container.
  • row creates the grid row.
  • col-12 creates a full-width column by default.
  • col-md-6 creates a half-width column from the medium breakpoint.
  • col-lg-4 creates a one-third-width column from the large breakpoint.
  • g-4 adds spacing between grid items.
  • h-100 can help cards fill the available height.
  • Bootstrap cards work well with the grid system.
  • Responsive classes follow Bootstrap's mobile-first approach.
  • Three columns can be created with 4 + 4 + 4 = 12.
  • Two columns can be created with 6 + 6 = 12.
  • Using col-12 col-md-6 col-lg-4 creates a common responsive card layout.
  • Bootstrap grid layouts can be created without custom media queries.
  • Always test your grid at different viewport widths.

🧠 Quick Quiz

Question: In Bootstrap's 12-column grid, which class creates a column that occupies 4 columns from the large breakpoint and above?