1.unit

删除或更换单位。

参数:

  • dimension: 带单位或不带单位的数字。
  • unit: (可选) 目标单位,如果省略此参数,则删除单位。

See convert for changing the unit without conversion.

案例: unit(5, px)

输出: 5px

案例: unit(5em)

输出: 5

2.ceil

向上取整。

参数: number - 浮点数。

返回值: 整数(integer)

案例: ceil(2.4)

输出: 3

3.floor

向下取整。

参数: number - 浮点数

返回值: 整数(integer)

案例: floor(2.6)

输出: 2

4.percentage

将浮点数转换为百分比字符串。

参数: number - 浮点数。

返回值: 字符串(string)

案例: percentage(0.5)

输出: 50%

5.round

四舍五入取整。

参数:

  • number: 浮点数
  • decimalPlaces: 可选:四舍五入取整的小数点位置。默认值为0。

返回值: 数字(number)

案例: round(1.67)

输出: 2

案例: round(1.67, 1)

输出: 1.7

 6.calc用法

在使用less时写

width:calc(100vh-274px);

但在浏览器检查元素的时候总会显示---width : calc(-174vh);

可以在Less中把calc的写法改写成下面这样:

calc(~"100vh - 274px");

这样编译就正常了

相关文章:

  • 2021-11-27
  • 2021-05-31
  • 2021-11-23
  • 2021-11-19
  • 2021-10-03
  • 2021-10-03
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-04
  • 2021-05-08
  • 2021-09-17
  • 2021-04-24
相关资源
相似解决方案