将Sass中的数字四舍五入并调整小数位数 [英] Rounding numbers in Sass and adjusting the amount of decimals

查看:141
本文介绍了将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更改日志:

现在可以在命令行中使用--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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆