使用 FxFlexModule 垂直定位元素

Position elements vertically using FxFlexModule

我在我的应用程序中使用 Angulars FxFlexModule。我需要将“测试”元素移近搜索框。整个容器(文本元素和搜索框)都使用 fxLayoutAlign="start start" fxLayoutGap="8px"。如何使用 FxFlexModule 将“测试”元素推到更靠近搜索框的位置?我不想使用绝对或相对定位。

我假设您的代码布局如下:

<div fxLayout="column" fxLayoutAlign="start start" fxLayoutGap="8px">
  <mat-form-field>...</mat-form-field>
  <div>test</div>
</div>

您可以删除 fxLayoutGap="8px",这会将“测试”向上移动 8 像素。

FxLayoutGap 还支持负边距,因此您可以尝试 fxLayoutGap="-8px"。如果您使用 mat-hints 和 mat-errors,请小心,在这种情况下,它们可能会与您的“测试”元素重叠。