有没有办法在一行中完成以下操作?
--widthA: get-vw(20px);
font-size: calc(5px + var(--widthA));
因为我需要设置一个最小的font-size
。 get-vw
函数将在 vw 中计算 20px,我需要在其上添加 5px。
最佳答案
是的,您可以使用 interpolation 将其写在一行中(不带变量) (#{...}
):
font-size: calc(5px + #{get-vw(20px)});
演示(带有示例功能): https://jsfiddle.net/wccoLefp/
Sass allows any text in these function calls, including nested parentheses. Nothing is interpreted as a SassScript expression, with the exception that interpolation can be used to inject dynamic values.
Sass: Special Functions
关于css - 如何在函数内部使用 calc()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46097871/