【发布时间】:2021-01-23 21:24:02
【问题描述】:
我在下面有这个 ngStyle,就像这样工作
[ngStyle]="{'height': true ? '100vh' : null }"
但是当我使用这样的计算时不起作用(被应用)
[ngStyle]="{'height': true ? 'calc(100vh-100px)' : null }"
谁能告诉我为什么?
【问题讨论】:
标签: html css angular calc ng-style
我在下面有这个 ngStyle,就像这样工作
[ngStyle]="{'height': true ? '100vh' : null }"
但是当我使用这样的计算时不起作用(被应用)
[ngStyle]="{'height': true ? 'calc(100vh-100px)' : null }"
谁能告诉我为什么?
【问题讨论】:
标签: html css angular calc ng-style
- 前后都需要空格。像这样-
[ngStyle]="{'height': true ? 'calc(100vh - 100px)' : null }"
【讨论】:
component.ts 中应用条件,例如。 - <some-element [ngStyle]="objExp">...</some-element> 或类似 <some-element [ngStyle]="getStyleObj()">...</some-element>