按照这个 link
我可以
<p [style.width.px]="30">
Some text that may be important.
</p>
这将设置宽度为 30 像素。
我如何对百分比做同样的事情?
<p [style.width.percent]="30"> // This doesn't work
Some text that may be important.
</p>
最佳答案
您使用 %
符号。
<p [style.width.%]="30">
您可以使用 CSS 中通常出现在数值之后的内容。
例如;
30rem => [style.width.rem]="30"
30px => [style.width.px]="30"
30% => [style.width.%]="30"
关于angular - 如何在 Angular 中应用带有百分比的样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56484111/