在 Sass 中舍入数字并调整小数位数 [英] Rounding numbers in Sass and adjusting the amount of decimals
问题描述
是他们在 sass 中更改舍入发生的数字的一种方式,我想停止将 2.0242914979757085% 这样的数字舍入到 2.024%.我想调整输出css中的小数位数
Is their a way in sass to change the digit that rounding occurs on, I would like to stop rounding of a number like this 2.0242914979757085% to this 2.024%. I would like to adjust the amount of decimals in the output css
推荐答案
来自 SASS 更改日志:
From the SASS change logs:
现在可以使用命令行的 --precision
选项设置 Sass 中数字的数值精度.此外,现在可以通过将 Sass::Script::Number.precision 设置为整数(默认为 3)来更改 Sass 输出中的默认精度位数.由于现在可以更改此值,因此不推荐使用 Sass::Script::Number 中的 PRECISION 常量.万一您在代码中使用它,您现在应该改用 Sass::Script::Number.precision_factor.
The numeric precision of numbers in Sass can now be set using the --precision
option to the command line. Additionally, the default number of digits of precision in Sass output can now be changed by setting Sass::Script::Number.precision to an integer (defaults to 3). Since this value can now be changed, the PRECISION constant in Sass::Script::Number has been deprecated. In the unlikely event that you were using it in your code, you should now use Sass::Script::Number.precision_factor instead.
这是在 SASS 3.1.8 中添加的.
This was added in SASS 3.1.8.
这篇关于在 Sass 中舍入数字并调整小数位数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!