FxLayoutAlign 中心正在工作

FxLayoutAlign center is working

我正在使用 material angular 并使用下面的代码,但使中心

<div fxLayout="column" fxLayoutAlign="center center">
      <span class="mat-display-2">Hello, Lemonite!</span>
      <button mat-raised-button color="primary">Login</button>
    </div>

这是一个例子:

<div fxLayout="column" fxLayoutAlign="center stretch">
  <span class="mat-display-2">Hello, Lemonite!</span>
  <button mat-raised-button color="primary">Login</button>
</div>
<div style="margin: 50px;"></div>
<div fxLayout="row" fxLayoutAlign="space-between center">
  <span class="mat-display-2" style="margin: 0;">Hello, Lemonite!</span>
  <button mat-raised-button color="primary">Login</button>
</div>

https://stackblitz.com/edit/center-test?file=app/app.component.html

此外,如果您尝试以不同的方式定位,请查看交互式演示:https://tburleson-layouts-demos.firebaseapp.com/#/docs

我知道你正在阅读的那本书有这个问题。它没有提到它,但您必须在 material 模块文件中导入 FlexLayoutModule。