How to center form using Bootstrap 4
Learn How to center Form using Bootstrap 4
It is common for every designer, while creating a form, to align it in Center. To align Form in center using Bootstrap 4, there are many ways. Method one is, you can use bootstrap’s inbuilt classes, or you can create your own CSS class to center align the form. Here in this article, we are going to use an inbuilt class to center align a form in Bootstrap 4. You can check out the following example. There is an inbuilt class called, justify-content-center. Just add this class to the form div block, as shown in the given code below.
Method-1
center-form.html
<!DOCTYPE html>
<html>
<head>
<title>Coding-zon Demo How to center form in Bootstrap 4</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="row justify-content-center">
<div class="col-4">
<h2> Login Form </h2>
<br><br><br>
<form method="POST" action="server_page.php" enctype="multipart/form-data">
<div class="form-group">
<label for="email">Email:</label>
<input type="email" class="form-control" id="email" placeholder="Enter email" name="email">
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="pwd" placeholder="Enter password" name="pwd">
</div>
<div class="checkbox">
<label><input type="checkbox" name="remember"> Remember me</label>
</div>
<div class="form-group">
<button type="submit" name="Submit" class="btn btn-success">Upload</button>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
Output:
I hope this tutorial is helpful. If it is useful, don’t forget to share it, who need this help.
If you have any queries, you can write in the below comment box. You will find more helping tips. So, you should continue to visit this tutorial blog for becoming an expert in the coding field.
Comments
Post a Comment