我正在尝试将我的Bootstrap表单水平和垂直对齐,使其位于屏幕中央;然而,我找不到任何解决方案来帮助我。
我尝试使用这些Bootstrap类,但它们没有起作用: d-flex align-items-center justify-content-center 这是我的表单:
我尝试使用这些Bootstrap类,但它们没有起作用: d-flex align-items-center justify-content-center 这是我的表单:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js" integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0" crossorigin="anonymous"></script>
<title>Login</title>
</head>
<body>
<div class="d-flex align-items-center justify-content-center">
<form>
<div class="mb-3 form-control-sm">
<label for="loginInputEmail" class="form-label">Email address</label>
<input type="email" class="form-control" id="loginInputEmail" aria-describedby="emailHelp">
<div id="emailHelp" class="form-text">We'll never share your email with anyone else.</div>
</div>
<div class="mb-3 form-control-sm">
<label for="loginInputPassword" class="form-label">Password</label>
<input type="password" class="form-control" id="loginInputPassword">
</div>
<div class="mb-3 form-control-sm">
<label for="selectAccountType" class="form-label">Account type</label>
<select class="form-select form-select-sm" id="selectAccountType" aria-label="selectAccountType">
<option selected>Account type</option>
<option value="1">Arbetare</option>
<option value="2">Företag</option>
<option value="3">Admin</option>
</select>
</div>
<div class="mb-3 form-check form-control-sm">
<input type="checkbox" class="form-check-input" id="rememberCheck">
<label class="form-check-label" for="rememberCheck">Remember me</label>
</div>
<button type="submit" class="btn btn-primary">Login</button>
</form>
</div>
</body>
</html>