本文介绍了可以使用LESS CSS舍入数字(数学项)吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
无需CSS = http://lesscss.org/
我这样声明了一个变量... @height: 30px
I declared a variable, like this... @height: 30px
然后我使用了一个简单的计算,就像这样... line-height: @height * .666
Then I used a simple calculation, like this... line-height: @height * .666
它返回19.98px
,但我想要一个20px
It returns 19.98px
but I wanted an even 20px
那么,LESS CSS是否有办法将数字向上或向下取整?
So, does LESS CSS have a way to round numbers up or down?
推荐答案
是的,他们可以:
line-height: ceil(@height * .666); // 20px (round up)
line-height: floor(@height * .666); // 19px (round down)
line-height: round(@height * .666); // 20px (round to closest integer)
line-height: round(@height * .666, 1); // 20.0px (round to 1 decimal place)
这篇关于可以使用LESS CSS舍入数字(数学项)吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!