Bootstrap 5 Center Alignment

Bootstrap 5 Center Alignment

Use the .mx-auto class to center-align elements (add margin-left and margin-right to auto):

<!DOCTYPE html>
<html>
<head>
  <title>Bootstrap5 demos</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/js/bootstrap.bundle.min.js"></script>
</head>
<body>

<div class="container mt-3">
  <div class="mx-auto bg-warning" style="width:150px">Center Alignment</div>
</div>

</body>
</html>

Output:

Bootstrap 5 Center Alignment

Like(1)