较少CSS = http://lesscss.org/
我声明了一个变量,就像这样...... @height: 30px
然后我用了一个简单的计算,就像这样...... line-height: @height * .666
它返回19.98px但我想要一个偶数20px
那么,LESS CSS是否有办法向上或向下舍入数字?
Pau*_*aul 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)
Run Code Online (Sandbox Code Playgroud)