I am looking to create an inline form with rows. Each row should include an input field that spans 5 columns, along with a button wrapped in content.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="87e5e8e8f3f4f3f5e6f7c7b2a9b5a9b4">[email protected]</a>/dist/css/bootstrap.min.css">
</head>
<body>
<div class=""> <!---no aligning--->
<form class="bg-dark">
<div class="row">
<div class="col-5"> <!---works well, input takes 5 columns--->
<input type="email" class="form-control" id="inputEmail" placeholder="Email">
</div>
<div class="col">
<button type="submit" class="btn btn-primary">Sign in</button>
</div>
</div>
</form>
</div>
</body>
My issue arises when I try to center the form horizontally and vertically within its parent div using classes like
d-flex justify-content-center align-items-center h-100
. While this centers the form, the input field no longer spans 5 columns as intended. By coloring the form grey and the parent div black, it is clear that the form does not occupy the entire width anymore.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="07656868737473756677473229352934">[email protected]</a>/dist/css/bootstrap.min.css">
</head>
<body>
<div class="d-flex justify-content-center align-items-center h-100 bg-secondary"> <!---center align--->
<form class="bg-dark">
<div class="row">
<div class="col-5"> <!---input doesn't take 5 columns--->
<input type="email" class="form-control" id="inputEmail" placeholder="Email">
</div>
<div class="col">
<button type="submit" class="btn btn-primary">Sign in</button>
</div>
</div>
</form>
</div>
</body>
Seeking guidance on how to properly center this form while maintaining the 5-column input layout. Can you provide assistance?