LESS 扩展嵌套选择器
LESS 扩展嵌套选择器
嵌套选择器可以匹配使用扩展选择器。
例子
<!--extend_syntax.htm--> <!doctype html> <head> <link rel = "stylesheet" href = "style.css" type = "text/css" /> </head> <body> <div class = "style"> <h3>Hello!!!!!</h3> </div> <p class = "img">Welcome to TutorialsPoint</p> </body> </html>
跟着下来创建style.less文件.
/*style.less*/ .style { h3 { color: #BF70A5; font-size: 30px; } } .img:extend(.style h3){}
使用下面命令编译less文件
lessc style.less style.css
得到css文件
/*style.css*/ .style h3, .img { color: #BF70A5; font-size: 30px; }
输出
执行以下步骤:
保存上面的 html 代码到 extend_syntax.html 文件。
在浏览器中打开该HTML文件,输出如下得到显示。