可以使用LESS CSS对数字进行四舍五入(数学术语)吗



LESS CSS=http://lesscss.org/

我声明了一个变量,像这样。。。@height: 30px

然后我用了一个简单的计算,像这样。。。line-height: @height * .666

它返回19.98px,但我想要一个均匀的20px

那么,LESS CSS有向上或向下取整数字的方法吗?

是的,他们可以:

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)

http://lesscss.org/functions/对于lesscss函数的列表,floor包含在"数学函数"的标题下。

最新更新