如何在 Angular 中应用带有百分比的样式? [英] How to apply style with percentage in Angular?
本文介绍了如何在 Angular 中应用带有百分比的样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
根据这个link
我能做到
<p [style.width.px]="30">
Some text that may be important.
</p>
这会将宽度设置为 30 像素.我如何对百分比做同样的事情?
This will set a width of 30 px. How do I do the same for percentage ?
<p [style.width.percent]="30"> // This doesn't work
Some text that may be important.
</p>
推荐答案
您使用 %
符号.
<p [style.width.%]="30">
您通常使用 CSS 中数值之后的内容.
You use what ever would normally come after the numeric value in CSS.
例如;
30rem => [style.width.rem]="30"
30px => [style.width.px]="30"
30% => [style.width.%]="30"
这篇关于如何在 Angular 中应用带有百分比的样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文