饥人谷技术博客

less入门

2017-01-07  本文已影响0人  GarenWang

1. 什么是less?

2.怎么使用less?

U95%(NHYI`WT~N}$I7QU5CW.png

less 语法

![)P%%TIDSPU%H{9HG]U_RODP.png](https://img.haomeiwen.com/i3361706/4f83994b44c59bb1.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

  1. 无参数,可以把写好.border直接写入div的样式中,结果如下图
    .border{
    border:1px solid #fff;
    }
    div{
    width:100px;
    height:100px;
    .border
    }

![MC$A1C0DBGK]8`4(G0KT5ZC.png](https://img.haomeiwen.com/i3361706/4717ddfe27d87851.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

2.有参数, 形式如.xxx(@变量)

   .border-01(@width){
          border: solid red @width;
    }
      .test{
          .one;
          .border-01(20px)
  }
1.png

3.参数可以传递默认值 .xxx(@变量:value)

    .border-02(@border_width:10px){
    border: solid red @border_width
   }
    div{
    .one;
    .border-02()//此时div的border默认宽度为10px;
    //也可以对默认值进行修改如  .border-02(20px);
    }

![F%HTLYTS1~H]POCDP`9KXJK.png](https://img.haomeiwen.com/i3361706/cc044452c4f98dc8.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

3.安装less的编译软件

上一篇 下一篇

猜你喜欢

热点阅读