UI Bootstrap/Bootstrap 3 - 如何让容器居中?

UI Bootstrap/Bootstrap 3 - How do I center a container?

我正在使用 Angularjs 创建一个简单的登录页面,并尝试使用 UI Bootstrap 添加 CSS。 UI Bootstrap 所需的依赖项之一是 Bootstrap CSS,因此我也将其包含在我的页面中。现在,我的表单看起来符合预期;我想要做的是将容器本身垂直居中,以便它位于页面的中间。有什么好办法让我去做那件事吗?我已经搜索了很多解决方案,它们要么不改变任何东西,要么以我不想要的方式 squash/change 表单本身。老实说,我不确定我难以将容器居中的原因是否与 UI Bootstrap 或任何其他因素有关。

这是表格的图片:

这是我的代码:

<!DOCTYPE html>
<html lang="en">
  <head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.9/angular.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/2.5.0/ui-bootstrap-tpls.min.js"></script>
  </head>
  <body>
    <!-- This is the div for the form component -->
    <div ng-app="form-component">
      <div class="container">
        <div class="row center-block">
          <div class="col-sm-4"></div>
          <div class="col-sm-4">
            <form>
              <div class="form-group">
                <label for="username">Username</label>
                <input type="text" class="form-control" id="username-input">
              </div>
              <div class="form-group">
                <label for="password">Password</label>
                <input type="password" class="form-control" id="password-input">
              </div>
              <div class="text-center">
                <button type="submit" class="btn btn-primary">Submit</button>
              </div>
            </form>
          </div> <!-- class="col-sm-4" -->
          <div class="col-sm-4"></div>
        </div> <!-- class="row justify-content-center" -->
      </div> <!-- class="container" -->
    </div> <!-- np-app form-component -->
    <script>
      var form = angular.module("form-component", ["ui.bootstrap"]);
    </script>
  </body>
</html>

非常感谢任何帮助,非常感谢。

试试这个

html, body {
  height: 100%
}

.wrapper {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.9/angular.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/2.5.0/ui-bootstrap-tpls.min.js"></script>
  </head>
  <body>
    <!-- This is the div for the form component -->
    <div ng-app="form-component" class="wrapper">
      <div class="container">
        <div class="row center-block">
          <div class="col-sm-4"></div>
          <div class="col-sm-4">
            <form>
              <div class="form-group">
                <label for="username">Username</label>
                <input type="text" class="form-control" id="username-input">
              </div>
              <div class="form-group">
                <label for="password">Password</label>
                <input type="password" class="form-control" id="password-input">
              </div>
              <div class="text-center">
                <button type="submit" class="btn btn-primary">Submit</button>
              </div>
            </form>
          </div> <!-- class="col-sm-4" -->
          <div class="col-sm-4"></div>
        </div> <!-- class="row justify-content-center" -->
      </div> <!-- class="container" -->
    </div> <!-- np-app form-component -->
    <script>
      var form = angular.module("form-component", ["ui.bootstrap"]);
    </script>
  </body>
</html>