lessFunction

1.color

body{
    background: color("#f00");
}

2.convert

body{
    background: color("#f00");
    width:convert(20cm,px)
} 

3.转化图片格式

body{
    background: color("#f00");
    width:convert(20cm,px);
    background: data-uri("../img/add.png");
}

4.排除其他default

body{
    background: color("#f00");
    width:convert(20cm,px);
    background: data-uri("../img/add.png");
    .x(23)
}
   .x(1){ x:11}                                     
   .x(2){ x:22}   
   .x(@x)when(default()){ z:@x}  

5.判断是否是px

 .y(@y) when (ispixel(@y)){widtg:@y}                                 
   .y(@y) when not(default()){padding:(@y*10)};
   .div1{
       .y(100px)
   } 
   
     .div3{
       .y(100cm);
       color: #ccc;
   } 

6.unit()改变单位

div{
    width: unit(100px,cm);
}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容