4 Program to show Text Alignment in BootStrap

Program:

<!DOCTYPE html>

<html lang="en">



<head>

  <meta charset="UTF-8">

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

  <meta http-equiv="X-UA-Compatible" content="ie=edge">

  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css"

    integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">

  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"

    integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">





  <title>Text Alignment & Display</title>

</head>



<body>



  <nav class="navbar navbar-expand-sm navbar-dark bg-success">

    <a class="navbar-brand" href="#">Text Alignment & Display in Bootstrap</a>

    <button class="navbar-toggler" data-toggle="collapse" data-target="#navbarNav">

      <span class="navbar-toggler-icon"></span>

    </button>

  </nav>



  <div class="container mt-5">

    <!--########################START HERE#########################-->



    <!-- TEXT JUSTIFY -->

    <p class="text-justify">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolor ad deleniti, placeat cumque,

      maiores fugiat

      tenetur ea voluptas voluptatem odio odit, dicta. Eaque reiciendis sed placeat omnis doloribus, corrupti eius.</p>



    <br><br>



    <!--TEXT ALIGNMENT -->

    <p class="text-left">Lorem ipsum dolor sit.</p>

    <p class="text-center">Lorem ipsum dolor sit.</p>

    <p class="text-right">Lorem ipsum dolor sit.</p>



    <!-- RESPONSIVE TEXT ALIGN -->

    <p class="text-sm-right">Right aligned on small or larger</p>

    <p class="text-md-right">Right aligned on medium or larger</p>

    <p class="text-lg-right">Right aligned on large or larger</p>

    <p class="text-xl-right">Right aligned on xl or larger</p>



    <br><br>



    <!-- TURN BLOCK TO INLINE -->

    <h1 class="d-inline bg-success">Hello</h1>

    <h1 class="d-inline bg-success">Goodbye</h1>



    <br><br>



    <!-- TURN INLINE TO BLOCK -->

    <span class="d-block bg-warning">Block</span>



    <br><br>



    <!-- INLINE BLOCK -->

    <div class="d-inline-block bg-info">

      <h3>Hello</h3>

      This is inline

    </div>

    <div class="d-inline-block bg-info">

      <h3>Hello</h3>

      This is inline

    </div>

  </div>



  <div style="margin-top:500px;"></div>



  <!-- BODY ENDS -->

</body>



</html>


Output:

text alignment in BootStrap

Previous
Next Post »