Bootstrap 4 - Flex



Description

Flex utility can be used to manage the layout, alignment, grid columns, navigation and other components of the page. It makes easy to design layout structure without using float or positioning.

Flex Behaviors and Direction

Use the flexbox display utilities like d-flex and d-inline-flex to display the flexbox container and children elements into flex items. You can set the direction of flex items in horizontal direction and vertical direction by using .flex-row (use .flex-row-reverse to display horizontal direction from the opposite side) and .flex-column (use .flex-column-reverse to display vertical direction from the opposite side) classes respectively as shown in the below example −

Example

<html>
   <head>
      <!-- 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://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
      <title>Bootstrap 4 Example</title>
   </head>
   
   <body>
      <div class = "container">
         <h2>Flex Behaviors</h2>
         <div class = "d-flex p-2 bg-info">
            This is flex container, uses the 'd-flex' class
         </div>
         <br>
         
         <div class = "d-inline-flex p-2 bg-info">
            This is inline flexbox container, uses the 'd-inline-flex' class
         </div>
         <br>
         <br>

         <h2>Direction</h2>
         <h4>Horizontal Direction</h4>
         <div class = "d-flex flex-row bg-info mb-3">
            <div class = "p-2 border border-dark ">flex-row: Item 1</div>
            <div class = "p-2 border border-dark">flex-row: Item 2</div>
            <div class = "p-2 border border-dark">flex-row: Item 3</div>
         </div>
         <div class = "d-flex flex-row-reverse bg-info">
            <div class = "p-2 border border-dark">flex-row-reverse: Item 1</div>
            <div class = "p-2 border border-dark">flex-row-reverse: Item 2</div>
            <div class = "p-2 border border-dark">flex-row-reverse: Item 3</div>
         </div>
         <br>

         <h4>Vertical Direction</h4>
         <div class = "d-flex flex-column bg-info mb-3">
            <div class = "p-2 border border-dark">flex-column: Item 1</div>
            <div class = "p-2 border border-dark">flex-column: Item 2</div>
            <div class = "p-2 border border-dark">flex-column: Item 3</div>
         </div>
         <div class = "d-flex flex-column-reverse bg-info">
            <div class = "p-2 border border-dark">flex-column-reverse: Item 1</div>
            <div class = "p-2 border border-dark">flex-column-reverse: Item 2</div>
            <div class = "p-2 border border-dark">flex-column-reverse: Item 3</div>
         </div>
      </div>
      
      <!-- jQuery first, then Popper.js, then Bootstrap JS -->
      <script src = "https://code.jquery.com/jquery-3.2.1.slim.min.js" 
         integrity = "sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" 
         crossorigin = "anonymous">
      </script>
      
      <!-- Popper -->
      <script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" 
         integrity = "sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" 
         crossorigin = "anonymous">
      </script>
      
      <!-- Latest compiled and minified Bootstrap JavaScript -->
      <script src = "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" 
         integrity = "sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" 
         crossorigin = "anonymous">
      </script>
      
   </body>
</html>

It will produce the following result −

Output

Justify Content

The alignment of flex items (such as start, end, center, between and around) can be changed on the main axis (x-axis to start) of the flexbox containers by using justify-content utility.

The following example demonstrates this −

Example

<html>
   <head>
      <!-- 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://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
      <title>Bootstrap 4 Example</title>
   </head>
   
   <body>
      <div class = "container">
         <h2>Alignment - Start</h2>
         <div class = "d-flex justify-content-start bg-info">
            <div class = "p-2 border border-dark">Item 1</div>
            <div class = "p-2 border border-dark">Item 2</div>
            <div class = "p-2 border border-dark">Item 3</div>
         </div>
         <br>
            
         <h2>Alignment - End</h2>
         <div class = "d-flex justify-content-end bg-info">
            <div class = "p-2 border border-dark">Item 1</div>
            <div class = "p-2 border border-dark">Item 2</div>
            <div class = "p-2 border border-dark">Item 3</div>
         </div>
         <br>
         
         <h2>Alignment - Center</h2>
         <div class = "d-flex justify-content-center bg-info">
            <div class = "p-2 border border-dark">Item 1</div>
            <div class = "p-2 border border-dark">Item 2</div>
            <div class = "p-2 border border-dark">Item 3</div>
         </div>
         <br>
         
         <h2>Alignment - Between</h2>
         <div class = "d-flex justify-content-between bg-info">
            <div class = "p-2 border border-dark">Item 1</div>
            <div class = "p-2 border border-dark">Item 2</div>
            <div class = "p-2 border border-dark">Item 3</div>
         </div>
         <br>
         
         <h2>Alignment - Around</h2>
         <div class = "d-flex justify-content-around bg-info">
            <div class = "p-2 border border-dark">Item 1</div>
            <div class = "p-2 border border-dark">Item 2</div>
            <div class = "p-2 border border-dark">Item 3</div>
         </div>
      </div>
      
      <!-- jQuery first, then Popper.js, then Bootstrap JS -->
      <script src = "https://code.jquery.com/jquery-3.2.1.slim.min.js" 
         integrity = "sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" 
         crossorigin = "anonymous">
      </script>
      
      <!-- Popper -->
      <script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" 
         integrity = "sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" 
         crossorigin = "anonymous">
      </script>
      
      <!-- Latest compiled and minified Bootstrap JavaScript -->
      <script src = "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" 
         integrity = "sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" 
         crossorigin = "anonymous">
      </script>
      
   </body>
</html>

It will produce the following result −

Output

Align Items

The alignment of flex items (such as start, end, center, baseline and stretch) can be changed on the cross axis (y-axis to start) of the flexbox containers by using align-items utility.

The following example demonstrates this −

Example

<html>
   <head>
      <!-- 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://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
      <title>Bootstrap 4 Example</title>
   </head>
   
   <body>
      <div class = "container">
         <h2>Align Items - Start</h2>
         <div class = "d-flex align-items-start bg-info" style = "height: 100px">
            <div class = "p-2 border border-dark">Item 1</div>
            <div class = "p-2 border border-dark">Item 2</div>
            <div class = "p-2 border border-dark">Item 3</div>
         </div>
         <br>
         
         <h2>Align Items - End</h2>
         <div class = "d-flex align-items-end bg-info" style = "height: 100px">
            <div class = "p-2 border border-dark">Item 1</div>
            <div class = "p-2 border border-dark">Item 2</div>
            <div class = "p-2 border border-dark">Item 3</div>
         </div>
         <br>
         
         <h2>Align Items - Center</h2>
         <div class = "d-flex align-items-center bg-info" style = "height: 100px">
            <div class = "p-2 border border-dark">Item 1</div>
            <div class = "p-2 border border-dark">Item 2</div>
            <div class = "p-2 border border-dark">Item 3</div>
         </div>
         <br>
         
         <h2>Align Items - Baseline</h2>
         <div class = "d-flex align-items-baseline bg-info" style = "height: 100px">
            <div class = "p-2 border border-dark">Item 1</div>
            <div class = "p-2 border border-dark">Item 2</div>
            <div class = "p-2 border border-dark">Item 3</div>
         </div>
         <br>
         
         <h2>Align Items - Stretch</h2>
         <div class = "d-flex align-items-stretch bg-info" style = "height: 100px">
            <div class = "p-2 border border-dark">Item 1</div>
            <div class = "p-2 border border-dark">Item 2</div>
            <div class = "p-2 border border-dark">Item 3</div>
         </div>
         <br>
      </div>
      
      <!-- jQuery first, then Popper.js, then Bootstrap JS -->
      <script src = "https://code.jquery.com/jquery-3.2.1.slim.min.js" 
         integrity = "sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" 
         crossorigin = "anonymous">
      </script>
      
      <!-- Popper -->
      <script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" 
         integrity = "sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" 
         crossorigin = "anonymous">
      </script>
      
      <!-- Latest compiled and minified Bootstrap JavaScript -->
      <script src = "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" 
         integrity = "sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" 
         crossorigin = "anonymous">
      </script>
      
   </body>
</html>

It will produce the following result −

Output

Fill, Grow and Shrink

The elements can be displayed into an equal widths on horizontal space by using .flex-fill class. The flex item will grow, if there is available space by using .flex-grow-* class and flex item will shrink, if necessary by using .flex-shrink-* class.

The following example demonstrates usage of above utilities −

Example

<html>
   <head>
      <!-- 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://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
      <title>Bootstrap 4 Example</title>
   </head>
   
   <body>
      <div class = "container">
         <h2>Fill</h2>
         <div class = "d-flex bg-info">
            <div class = "p-2 flex-fill border border-dark">Item 1</div>
            <div class = "p-2 flex-fill border border-dark">Item 2</div>
            <div class = "p-2 flex-fill border border-dark">Item 3</div>
         </div>
         <br>
         
         <h2>Grow</h2>
         <div class = "d-flex bg-info">
            <div class = "p-2 flex-grow-1 bg-info">Item 1 (Using class flex-grow-1)</div>
            <div class = "p-2 bg-warning">Item 2</div>
            <div class = "p-2 bg-secondary">Item 3</div>
         </div>
         <br>
         
         <h2>Shrink</h2>
         <div class = "d-flex bg-info">
            <div class = "p-2 w-100 bg-info">Item 1</div>
            <div class = "p-2 flex-shrink-1 bg-warning">Item 2 (Using class flex-shrink-1)</div>
         </div>
      </div>
      
      <!-- jQuery first, then Popper.js, then Bootstrap JS -->
      <script src = "https://code.jquery.com/jquery-3.2.1.slim.min.js" 
         integrity = "sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" 
         crossorigin = "anonymous">
      </script>
      
      <!-- Popper -->
      <script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" 
         integrity = "sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" 
         crossorigin = "anonymous">
      </script>
      
      <!-- Latest compiled and minified Bootstrap JavaScript -->
      <script src = "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" 
         integrity = "sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" 
         crossorigin = "anonymous">
      </script>
      
   </body>
</html>

It will produce the following result −

Output

Auto Margins and With align-items

The flex utility provides auto margin feature on the flex items by using the .mr-auto (pushes items to the right) and .ml-auto (pushes items to the left) classes. The flex items can be moved to top or bottom by using mt-auto or mb-auto classes on a container.

The following example demonstrates usage of above classes −

Example

<html>
   <head>
      <!-- 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://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
      <title>Bootstrap 4 Example</title>
   </head>
   
   <body>
      <div class = "container">
         <h2>Auto Margins</h2>
         <div class = "d-flex bg-info mb-3">
            <div class = "p-2 bg-warning">Item 1</div>
            <div class = "p-2 bg-primary">Item 2</div>
            <div class = "p-2 bg-secondary">Item 3</div>
         </div>
         <div class = "d-flex bg-info mb-3">
            <div class = "mr-auto p-2 bg-warning">mr-auto: Item 1</div>
            <div class = "p-2 bg-primary">Item 2</div>
            <div class = "p-2 bg-secondary">Item 3</div>
         </div>
         <div class = "d-flex bg-info mb-3">
            <div class = "p-2 bg-secondary">Item 1</div>
            <div class = "p-2 bg-primary">Item 2</div>
            <div class = "ml-auto p-2 bg-warning">ml-auto: Item 3</div>
         </div>
         
         <h2>With align-items</h2>
         <div class = "d-flex align-items-start flex-column bg-info mb-3" 
            style = "height: 200px;">
            
            <div class = "mb-auto p-2 bg-warning">mb-auto: Item 1</div>
            <div class = "p-2 bg-primary">Item 2</div>
            <div class = "p-2 bg-secondary">Item 3</div>
         </div>
         <div class = "d-flex align-items-end flex-column bg-info mb-3" 
            style = "height: 200px;">
            <div class = "p-2 bg-secondary">Item 1</div>
            <div class = "p-2 bg-primary">Item 2</div>
            <div class = "mt-auto p-2 bg-warning">mt-auto: Item 3</div>
         </div>
      </div>
      
      <!-- jQuery first, then Popper.js, then Bootstrap JS -->
      <script src = "https://code.jquery.com/jquery-3.2.1.slim.min.js" 
         integrity = "sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" 
         crossorigin = "anonymous">
      </script>
      
      <!-- Popper -->
      <script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" 
         integrity = "sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" 
         crossorigin = "anonymous">
      </script>
      
      <!-- Latest compiled and minified Bootstrap JavaScript -->
      <script src = "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" 
         integrity = "sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" 
         crossorigin = "anonymous">
      </script>
      
   </body>
</html>

It will produce the following result −

Output

Order

The flex uses order utilities to change the order of flex items in a container as shown in the following example −

Example

<html>
   <head>
      <!-- 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://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
      <title>Bootstrap 4 Example</title>
   </head>
   
   <body>
      <div class = "container">
         <h2>Flex Items Order</h2>
         <div class = "d-flex flex-nowrap bg-info">
            <div class = "order-3 p-2 bg-secondary">'order-3': Item 1</div>
            <div class = "order-1 p-2 bg-primary">'order-1': Item 2</div>
            <div class = "order-2 p-2 bg-warning">'order-2': Item 3</div>
         </div>
      </div>
      
      <!-- jQuery first, then Popper.js, then Bootstrap JS -->
      <script src = "https://code.jquery.com/jquery-3.2.1.slim.min.js" 
         integrity = "sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" 
         crossorigin = "anonymous">
      </script>
      
      <!-- Popper -->
      <script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" 
         integrity = "sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" 
         crossorigin = "anonymous">
      </script>
      
      <!-- Latest compiled and minified Bootstrap JavaScript -->
      <script src = "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" 
         integrity = "sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" 
         crossorigin = "anonymous">
      </script>
      
   </body>
</html>

It will produce the following result −

Output

Align Content

You can align (such as start, end, center, between and around) the flex items on the cross axis on the container by using align-content utility.

The following example demonstrates this −

Example

<html>
   <head>
      <!-- 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://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
      <title>Bootstrap 4 Example</title>
   </head>
   
   <body>
      <div class = "container">
         <h2>align-content-start</h2>
         <div class = "d-flex bg-info align-content-start flex-wrap" style = "height: 150px">
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
         </div>
         <br>
         
         <h2>align-content-end</h2>
         <div class = "d-flex bg-info align-content-end flex-wrap" style = "height: 150px">
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
         </div>
         <br>
         
         <h2>align-content-center</h2>
         <div class = "d-flex bg-info align-content-center flex-wrap" style = "height: 150px">
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
         </div>
         <br>
         
         <h2>align-content-between</h2>
         <div class = "d-flex bg-info align-content-between flex-wrap" style = "height: 150px">
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
         </div>
         <br>
         
         <h2>align-content-around</h2>
         <div class = "d-flex bg-info align-content-around flex-wrap" style = "height: 150px">
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
            <div class = "p-2 border border-dark">Demo Item</div>
         </div>
         <br>
      </div>
      
      <!-- jQuery first, then Popper.js, then Bootstrap JS -->
      <script src = "https://code.jquery.com/jquery-3.2.1.slim.min.js" 
         integrity = "sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" 
         crossorigin = "anonymous">
      </script>
      
      <!-- Popper -->
      <script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" 
         integrity = "sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" 
         crossorigin = "anonymous">
      </script>
      
      <!-- Latest compiled and minified Bootstrap JavaScript -->
      <script src = "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" 
         integrity = "sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" 
         crossorigin = "anonymous">
      </script>
      
   </body>
</html>

It will produce the following result −

Output

bootstrap4_utilities.htm
Advertisements