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

时间:2013-07-05 18:57:37

标签: less

LESS CSS = http://lesscss.org/

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

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

它会返回19.98px,但我想要一个偶数20px

那么,LESS CSS是否有办法向上或向下舍入数字?

2 个答案:

答案 0 :(得分:34)

是的,他们可以:

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)

答案 1 :(得分:2)

http://lesscss.org/functions/有关lesscss函数的列表,floor包含在“数学函数”标题下。