示例:
- isnumber(12); // true
- isnumber(#333); // false
- isunit(12px, px); // true
- isurl(url(...)); // true
示例:
- .main{
- width: if((2 > 1), 10px, 20px);
- }
-
- @dark: boolean(2 > 1);
-
- span{
- color: if(@dark, #000, #fff);
- }
示例:
- ceil(2.1); // 3
- percentage(0.5); // 50%
- min(2px, 20px, 10px, 3px); // 2px
示例:
- escape("id=22"); // id%3D22
-
- @var: "hello";
- .active:before{
- content: e(@var); // hello
- }
-
- replace("hello, world", "world", "God"); // "hello, God"
示例:
- length(2px 3px 4px); // 3
- extract(2% 3% 4%, 2); // 3%
-
- each(2px 3px 4px, {
- .item-{@index} {
- margin: @value;
- }
- })
- // 编译后
- .item-1 {
- margin: 2px;
- }
- .item-2 {
- margin: 3px;
- }
- .item-3 {
- margin: 4px;
- }
示例:
- color("#333"); // #333
- lighten(hsl(90, 80%, 50%), 20%); // #b3f075
- mix(#ff0000, #0000ff, 50%); // #800080
示例:
- image-size("file.png"); // 20px 30px
- image-width("file.png"); // 20px
- convert(10cm, mm); // 100mm