less 一个 css 预处理器
注释
运算
.box {
width: 100 + 10px; // 110px;
width: 100 - 20px; // 80px;
width: 100 * 2px; // 200px;
// 除法
// 推荐小括号写法
width: (100 / 4px); // 25px;
// 不支持 height: 100 ./ 4px; // 25px;
}
.box {
width: 110px;
width: 80px;
width: 200px;
width: 25px;
}
嵌套
.father {
color: red;
.son {
width: 100px;
}
}
.father {
color: red;
}
.father .son {
width: 100px;
}
& 表示当前选择器
变量
// 定义变量
@变量名:值;
// 使用变量
CSS属性:@变量名;
@color: red;
.box {
color: @color;
}
.box {
color: red;
}
导入 less 文件
导出 css 文件
VS Code 插件 Easy Less 设置 settings.json
{
"less.compile": {
"out": "../css/"
}
}