Open In App

Does Bootstrap 3 used Flexbox ?

Bootstrap 3 used floats to handle the layout in place of the flexbox, however, Bootstrap 4 uses flexbox to handle the layout. The flexbox layout makes it easier to design a flexible responsive layout structure without using float or positioning. Therefore, we use Bootstrap 4 in place of Bootstrap 3 for the flexible design purpose.

Approach:



Bootstrap CDN: We need to add the following CDN files within the HTML head element. 

<link rel=”stylesheet” href=”https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css”>
<script src=”https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js”></script>
<script src=”https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.bundle.min.js”></script>



Example: In this example, we have used flexbox to align the cards in the center vertically and to the right horizontally using the flex properties.




<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet"
          href=
    <script src=
    </script>
    <script src=
    </script>
    <style>
        .bg-container {
            background-image: url(
            );
            background-size: cover;
            height: 100vh;
        }
 
        .card {
            background-color:#19f7ecea;
            padding: 20px;
            width: 600px;
            height: 200px;
            border-radius: 15px;
            margin-right: 30px;
        }
 
        .main-heading {
            color: rgba(0, 0, 0, 0.849);
            font-family: "Bree Serif";
            font-size: 30px;
        }
 
        .paragraph1 {
            font-family: "Roboto";
            font-size: 15px;
        }
 
        .paragraph2 {
            font-size: 25px;
        }
 
        .button-container {
            text-align: center;
            margin: 10px;
        }
 
        .button {
            border-radius: 10px;
            background-color:#19f7ecea;
            padding: 5px;
            margin-top:40px;
            width: 250px;
            font-size: 20px;
            font-family: "Roboto";
        }
      </style>
</head>
<body>
    <div class="bg-container
                d-flex
                flex-row
                justify-content-end
                align-items-center">
        <div class="card">
            <h1 class="main-heading">
              Data Structure in C++ by Jitendra Kumar
            </h1>
            <p class="paragraph1">
              This course designed for beginners who wants to
              improve their programming skills and get ready
              for placement.</p>
 
 
            <p class="paragraph2">12000/-</p>
 
 
            <div class="button-container">
                <button class="button">Register Now</button>
            </div>
        </div>
        <div class="card">
            <h1 class="main-heading">
              Blockchain Technology
              by Vinod Kumar
            </h1>
            <p class="paragraph1">
              This course designed for college student
              who wants to know about basic knowledge
              of Blockchain.
            </p>
 
 
            <p class="paragraph2">20000/-</p>
 
 
            <div class="button-container">
                <button class="button">
                  Register Now
                </button>
            </div>
        </div>
     </div>
</body>
</html>

Output:


Article Tags :