为什么align-items-center在Bootstrap4中不起作用?

时间:2019-07-18 17:12:04

标签: bootstrap-4

How the stuff works in answered question

How the stuff works for me

好,所以我正在使用Bootstrap4,并且试图将主容器垂直居中。出于某种原因,它不起作用:/

Page Screenshot

None
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

1 个答案:

答案 0 :(得分:1)

我可以为您提供此documentation about vartical-align。 您应该了解,您需要一些元素(例如图片)才能看到一些差异。或者您想得到另一个东西?绘制您的预期输出。

也请阅读此answer

我的工作示例需要white page,因为它也不能用作您的页面。问题出在预定义的项目中。查找您不允许使用此解决方案的内容

<body>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<div class="container h-100">
    <div class="row align-items-center h-100">
        <div class="col-6 mx-auto">
            <div class="jumbotron text-center">
                <h1 class="display-4">Jumbotron</h1>
                <p class="lead">This is a simple centered hero unit.</p>
                <p class="lead">
                    <a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a>
                </p>
            </div>
        </div>
    </div>
</div>

<style>
body,html {
  height: 100%;
}  
</style>
</body>