gpt4 book ai didi

less - 可以使用LESS CSS舍入数字(数学术语)吗?

转载 作者:行者123 更新时间:2023-12-03 15:15:59 25 4
gpt4 key购买 nike

更少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)

关于less - 可以使用LESS CSS舍入数字(数学术语)吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17495302/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com