Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
384 views
in Technique[技术] by (71.8m points)

css - Sass and rounding down numbers. Can this be configured?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...