How to align vertical center button text in bootstrap?
April 21, 2022Hi Friends 👋,
Welcome To aGuideHub! ❤️
In this tutorial, we will learn the available class used for .text-center
in Bootstrap.
Here, we will use the text-center class to make a button in text center.
You can simply use the built-in class .text-center
on the wrapper element to center align buttons or other inline elements in Bootstrap. It will work in both Bootstrap 4 and 5 versions.
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">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<title>Buttons</title>
</head>
<body>
<div class="col-md-12 text-center">
<div class="btn-group-toggle" data-toggle="buttons">
<label class="btn btn-warning active">
Checked
<input type="checkbox" checked autocomplete="off">
</label>
</div>
</div>
<!-- Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
</body>
</html
Check the output of the above code example.
All the best 👍