Open In App

Bootstrap 5 Display

With Bootstrap 5 display tools, you can easily and quickly change the display value of components and more. With the help of Bootstrap responsive display utility classes, you may modify the value of the display property. For presentation purposes, we purposefully only support a portion of all potential values. You can combine classes for a variety of effects as needed.

Example 1: The following code demonstrates Bootstrap display using various classes like d-inline p-2 bg-warning text-dark,d-inline p-2 bg-dark text-white,d-inline p-2 bg-primary text-white,d-inline p-2 bg-dark text-primary.




<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Bootstrap CDN -->
    <link href=
        rel="stylesheet" integrity=
"sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" 
        crossorigin="anonymous">
     <!-- JavaScript Bundle with Popper -->
    <script src=
        integrity=
"sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" 
        crossorigin="anonymous">
    </script>
</head>
<body>
    <h1 class="text-center text-success">
        GeeksforGeeks
    </h1>
    <h2 class="text-center">
        Bootstrap 5 Display
    </h2>
    <br>
    <center>
        <div class="d-inline p-2 
            bg-warning text-dark">
            D-Inline
        </div>
        <div class="d-inline p-2 bg-dark 
            text-white">
            D-Inline
        </div>
        <div class="d-inline p-2 bg-primary 
            text-white">
            D-Inline
        </div>
        <div class="d-inline p-2 bg-dark 
            text-primary">
            D-Inline
        </div>
    </center>
</body>
</html>

Output:

Example 2: The following code demonstrates Bootstrap display using various classes like d-block p-2  bg-warning text-dark,d-block p-2 bg-dark text-white,d-block p-2 bg-primary text-white,d-block p-2 bg-dark text-primary.




<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Bootstrap CDN -->
    <link href=
        rel="stylesheet" integrity=
"sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" 
        crossorigin="anonymous">
    <!-- JavaScript Bundle with Popper -->
    <script src=
           integrity=
"sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" 
        crossorigin="anonymous">
    </script>
</head>
<body>
    <h1 class="text-center text-success">
        GeeksforGeeks
    </h1>
    <h2 class="text-center">
        Bootstrap 5 Display
    </h2>
    <br>
    <center>
        <span class="d-block p-2 
            bg-warning text-dark">
            d-block
        </span>
        <span class="d-block p-2 
            bg-dark text-white">
            d-block
        </span>
        <span class="d-block p-2 
            bg-primary text-white">
            d-block
        </span>
        <span class="d-block p-2 
            bg-dark text-primary">
            d-block
        </span>
    </center>      
</body>
</html>

Output:

 

References: https://getbootstrap.com/docs/5.0/utilities/display/#display-in-print


Article Tags :