相关疑难解决方法(0)

Bootstrap 4中心垂直和水平对齐

我有一个只存在表单的页面,我希望将表单放在屏幕的中心.

<div class="container">
  <div class="row justify-content-center align-items-center">
    <form>
      <div class="form-group">
        <label for="formGroupExampleInput">Example label</label>
        <input type="text" class="form-control" id="formGroupExampleInput" placeholder="Example input">
      </div>
      <div class="form-group">
        <label for="formGroupExampleInput2">Another label</label>
        <input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Another input">
      </div>
    </form>   
  </div>  
</div>
Run Code Online (Sandbox Code Playgroud)

justify-content-center对齐表格水平,但我无法弄清楚如何垂直对齐.我试过使用align-items-centeralign-self-center,但它不起作用.

我错过了什么?

DEMO

css centering twitter-bootstrap bootstrap-4

126
推荐指数
7
解决办法
30万
查看次数

标签 统计

bootstrap-4 ×1

centering ×1

css ×1

twitter-bootstrap ×1