Bootstrap 4 使用bootstrap 4创建表单

Bootstrap 4 使用bootstrap 4创建表单,bootstrap-4,Bootstrap 4,我使用的是Bootstrap4Beta2,我无法在页面上居中放置表单 这是我的代码链接 本韦努托 中尉 密码 登录 将以下css应用于父div 更新的cdoepen 将以下css应用于父div 更新的cdoepen 您需要先将html和身高设置为100% html, body { height: 100%; } 然后将容器高度设置为100% <div class="container h-100"> <div class="row justify-conte

我使用的是Bootstrap4Beta2,我无法在页面上居中放置表单

这是我的代码链接


本韦努托
中尉
密码
登录

将以下css应用于父div

更新的cdoepen


将以下css应用于父div

更新的cdoepen


您需要先将html和身高设置为100%

html, 
body {
    height: 100%;
}
然后将容器高度设置为100%

<div class="container h-100">
  <div class="row justify-content-center h-100 align-middle">
    <div class="align-self-center">
        <form>
          <h2 class="text-center">Benvenuto</h2>
            <div class="form-group">
                <label for="username">Utente</label>
                <input type="text"  class="form-control"  id="username" >
            </div>
            <div class="form-group">
                <label for="password">Password</label>
                <input type="password" class="form-control"  id="password" >
           </div>
            <button class="btn btn-lg btn-primary btn-block" type="submit">Login</button>
        </form>
    </div>
  </div>

本韦努托
中尉
密码
登录


现在,
align self-center
将获得垂直空间。

您需要先将html和身高设置为100%

html, 
body {
    height: 100%;
}
然后将容器高度设置为100%

<div class="container h-100">
  <div class="row justify-content-center h-100 align-middle">
    <div class="align-self-center">
        <form>
          <h2 class="text-center">Benvenuto</h2>
            <div class="form-group">
                <label for="username">Utente</label>
                <input type="text"  class="form-control"  id="username" >
            </div>
            <div class="form-group">
                <label for="password">Password</label>
                <input type="password" class="form-control"  id="password" >
           </div>
            <button class="btn btn-lg btn-primary btn-block" type="submit">Login</button>
        </form>
    </div>
  </div>

本韦努托
中尉
密码
登录


现在,
align self-center
将获得垂直放置的空间。

检查下面的我的答案检查下面的我的答案