引导 4 内容不会水平和垂直对齐居中



在Bootstrap 4中,我似乎无法将内容垂直和水平地放在页面主体的中心。我在整个StackOverflow中使用了文档和多个答案,而那些有相同问题的人都没有用。我不确定为什么这不起作用。感谢您的帮助和解释。

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
<div class="container-fluid h-100">
<div class="row h-100 justify-content-center align-items-center">
<div class="col-sm-12">
<h1>This is the test</h1>
<a href="#">Let's get started</a>
</div>
</div>
</div>

希望它能帮助你轻松

<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Align Center Examples</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="jumbotron text-center">
<h1>Working In center</h1>
<p>Well, Hope your Issue is Solved..</p>
</div>
</body>
</html>

最新更新