LESS是动态样式语言,赋予CSS动态语言的特性,如变量、继承、运算、函数,使得CSS更方便编写与维护。>>官网

less

@color:#ff0000;
body{color:@color;}

编译后

bosy{color:ff0000;}

一:命令行用法:

安装:

npm install -g less

解析styles.less

lessc styles.less

解析styles.less到styles.css

lessc styles.less styles.css

注意: 如果文件路径带有中文会编译不成功

二:浏览器端使用:

1、引入rel属性的值是stylesheet/less的.less样式表:

<link rel="stylesheet" href="test.less">

2、下载less脚本,放在自己项目中:

<script src="js/less.js" type="text/javascript"></script>    

或引用:

<script src="http://cdn.bootcss.com/less.js/1.7.0/less.min.js"></script>

在线LESS编译器>>

语法:

变量

@color:#ff0000;
body{color:@color;}

输出:

body{color:#ff0000;}

混合

.bd{border:1px solid #000;}
.a{.bd}

输出:

.a{border:1px solid #000;}

带参数混合

.box(@height){
height:@height;
line-height:@height;
}
.a{.box(25px);}

输出:

.a {
height: 25px;
line-height: 25px;
}

嵌套:

.box{
.a{color:blue;}
.c{&:hover{color:yellow}}
}

输出:

.box .a{color:blue;}
.box .c:hover{color:yellow;}

命名空间

.box{
.a{color:red;}
} body{
.box > .a;
}

输出:

body {
color: red;
}

作用域

@color:red;
body{
@color:#ffff00;
color:@color;
}

输出:

body {
color: #ffff00;
}

在不同软件中的使用:

FIS3中使用less

Webstorm实时编译LESS

less在sublime中使用

让Less在Dreamweaver中高亮显示

随机推荐

  1. 【bzoj4896】补退选

    傻逼题. 每个点维护下vector,然后随便做. #include<bits/stdc++.h> ; using namespace std; typedef long long ll; ...

  2. mybatis模糊查询sql

    今天下午做的一个功能,要用到模糊查询,字段是description,刚开始我的写法用的是sql中的模糊查询语句, 但是这个有问题,只有将字段的全部值传入其中,才能查询,所以不是迷糊查询. 后来经过搜索 ...

  3. HDU - 2818

    Building Block Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  4. HDU-5360

    Hiking Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Su ...

  5. resteasy json

    https://www.cnblogs.com/toSeeMyDream/p/5763725.html

  6. 半透明AlphaBlend

    AlphaBlend 函数功能:该函数用来显示透明或半透明像素的位图. 函数原型: BOOL AlphaBlend( HDC hdcDest, // handle to destination DC ...

  7. 在JAVASCRIPT中构建一个复杂的对象,并用JSON进行转换

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  8. Ubuntu Nginx

    如果是阿云的ECS服务器,默认是已经安装了Apache服务器的,但一般都用不到,可以选择将它卸载 sudo service apache2 stop update-rc.d -f apache2 re ...

  9. Codeforces 1131 C. Birthday-暴力 (Codeforces Round #541 (Div. 2))

    C. Birthday time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...

  10. java 中整数类型的进制转换

    int a=10; Integer.toBinaryString(a); //转换成2进制Integer.toOctalString(a);  //转换成8进制Integer.toHexString( ...