LESS 解锁将修改规则集的作用范围
LESS 解锁将修改规则集的作用范围
分离的规则集可以通过导入到它来获得对范围的访问权限。
例子
<!--passing_ruleset.htm--> <!doctype html> <head> <link rel = "stylesheet" href = "style.css" type = "text/css" /> </head> <body> <div class = "cont"> <h2>Welcome to TutorialsPoint</h2> <p>The largest Tutorials Library on the web.</p> </div> </body> </html>
创建style.less文件.
/*style.less*/ #id { .style() { @detached: { font-style: @font; }; } } .container() { @font: italic; #id > .style(); } .cont { .container(); @detached(); }
使用下面命令编译less文件
lessc style.less style.css
得到css文件
/*style.css*/ .cont { font-style: italic; }
输出
执行下面步骤:
保存上述代码到passing_ruleset.htm文件.
在浏览器中查看效果.