Sass和舍入数字。这可以配置吗? [英] Sass and rounding down numbers. Can this be configured?

查看:85
本文介绍了Sass和舍入数字。这可以配置吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有什么办法修改Sass处理小数位的方式吗?我看到一些人说Sass将动态地做响应布局所需的(目标/父)* 100计算,并在编译时输出结果。它甚至有一个百分比函数,这将基本上采取两个值,这样做。



唉,Sass只会给我3个小数位。对于这一点,我的理解是,在某些情况下,这可能不是足够的准确度,所有浏览器正确显示布局没有任何打嗝。





解决了这个问题。

其他任何人都有兴趣,我设法在Sass的number.rb中完成我想要的,改变@precision的值。

解决方案

如果您正在使用Compass,可以轻松地指定项目文件中的精度(config.rb)而不破坏核心:

  Sass :: Script :: Number.precision = 8 

有关详细信息,请参阅 Sass documentation


Is there any way for me to modify the way that Sass will handle decimal places? I saw a few people saying that Sass will dynamically do the (target/parent)*100 calculation needed for responsive layouts, and output the result at compile time. It even has a percentage function, which will essentially take the two values and do this.

Alas, Sass will only ever give me 3 decimal places. My understanding up to this point has been that in some cases, this may not be a sufficient degree of accuracy for all browsers to properly display the layout without any hiccups.

Can anyone help me get to the bottom of this?

EDIT

Solved. Incase anyone else is interested, I managed to accomplish what I wanted in Sass's number.rb, changing the value of @precision. This alters the way all floats are output.

解决方案

If you are using Compass, you can easily specify the precision in your project file (config.rb) without hacking the core:

Sass::Script::Number.precision = 8

For more information see Sass documentation

这篇关于Sass和舍入数字。这可以配置吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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