How to use justify content in bootstrap?

Hi Friends 👋,

Welcome To aGuideHub! ❤️

Today, I am going to show you. How to use justify content in bootstrap with code example.

Table of contents

  • Framework and cdn link
  • Included JS bootstrap
  • Define its class name

This article will guide you to adding justify content in Bootstrap with example.

Step 1: Framework and cdn link

First of all, load the Bootstrap framework CSS into the head tag of your webpage.

    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous">

Step 2: Included JS bootstrap

Now, load the Bootstrap JavaScript file before closing the body tag and done.

<!--Bootstrap 5 JS included-->  
   <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
   <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-fQybjgWLrvvRgtW6bFlB7jaZrFsaBXjsOMm/tB9LTS58ONXgqbR9W8oWht/amnpF" crossorigin="anonymous"></script>

Step 3: Define its class name

After that, create the justify-content with a class name .justify-content.

    <h2 class="d-flex justify-content-center">Justify content in bootstrap</h2>
    <div class="d-flex justify-content-start">Justify content start</div>
    <div class="d-flex justify-content-end">Justify content end</div>
    <div class="d-flex justify-content-center">Justify content center</div>
    <div class="d-flex justify-content-between">Justify content between</div>
    <div class="d-flex justify-content-around">Justify content around</div>

Example.

Let’s look at the following example to understand how it basically works:

<!doctype html>
<html lang="en">

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous">

    <title>Bootstrap</title>
</head>

<body>
    <h2 class="d-flex justify-content-center">Justify content in bootstrap</h2>
    <div class="d-flex justify-content-start">Justify content start</div>
    <div class="d-flex justify-content-end">Justify content end</div>
    <div class="d-flex justify-content-center">Justify content center</div>
    <div class="d-flex justify-content-between">Justify content between</div>
    <div class="d-flex justify-content-around">Justify content around</div>

    <!-- Option 1: jQuery and Bootstrap Bundle (includes Popper) -->
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-fQybjgWLrvvRgtW6bFlB7jaZrFsaBXjsOMm/tB9LTS58ONXgqbR9W8oWht/amnpF" crossorigin="anonymous"></script>


</body>

</html>

Check the output of the above code example.

Bootstrap, Justidy, Content

All the best 👍