angular - 如何正确使用@angular/flex-layout?

标签 angular flexbox angular-flex-layout

我正在使用 @angular/flex-layout 创建网络应用程序.

当屏幕小于 600px (xs) 时,我尝试左右留出 5% 的边距。它在大屏幕上工作正常(当有 fxLayout="row"-layout 时),但在 xsfxLayout="column"-情况。

Here is a demonstration in Plunker.

问题:如何让div填充右边的剩余空间,但只占90%左右偏移 5%?

最佳答案

最后,我使用了与@Nehal 类似的方法,但我使用了 ngClass.xs 而不是 ngStyle.xs 并让它工作正常。

<div fxLayout.xs="column"
     fxLayout.gt-xs="row"
     fxFlex.xs="grow"
     fxFlex.gt-xs="grow">
  <div ngClass.xs="section-title-xs-margin"
       fxFlex.xs="90"
       fxFlex.gt-xs="25"
       fxFlex.gt-sm="20"
       fxFlexOffset.xs="5"
       fxFlexOffset.gt-xs="5"
       fxFlexOffset.gt-sm="10">
    Left / Top
  </div>
  <div ngClass.xs="content-xs-margin"
       fxFlex.xs="90"
       fxFlex.gt-xs="63"
       fxFlex.gt-sm="55"
       fxFlexOffset.xs="5"
       fxFlexOffset.gt-xs="2"
       fxFlexOffset.gt-sm="5">
    Right / Bottom
  </div>
</div>

在 CSS 中:

.section-title-xs-margin {
  margin-right: 5%;
}

.content-xs-margin {
  margin-right: 5%;
}

关于angular - 如何正确使用@angular/flex-layout?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45175899/

相关文章:

javascript - 如何防止 Angular Material 垫菜单关闭?

仅 CSS 水平滚动画廊,带有各种尺寸的图像

css - Angular Flex 布局总是显示滚动条

css - 如何将 Material UI 选项卡移动到 AppBar 等父项的底部?

css - Angular 5 material flex-layout fxLayoutAlign ="space-evenly center"不工作

Angular/弹性布局不适用于 Angular 9

Angular 8 : How to use a Multi-Content-Projection/Multiple-Transclusion slot twice?

javascript - 使用 Angular 2 和 Node.js 下载不支持 Firefox 的 PDF

javascript - 将自定义图像添加到可重用的 Angular 组件

angular - 找不到模块 : Error: Can't resolve '@angular/flex-layout' in '/app'