LESS选择器插值扩展
LESS选择器插值扩展
@{变量}符号可以作为变量名、id和类名的一部分。Extend不具有匹配变量与变量的能力。扩展可以连接到插值选择器。
例子
<!--extend_syntax.htm--> <!doctype html> <head> <link rel = "stylesheet" href = "style.css" type = "text/css" /> </head> <body> <h2 class = "style">This is a simple example of Selector Interpolation</h2> <p class = "style">This is a simple example of Selector Interpolation</p> </body> </html>
创建style.less文件.
/*style.less*/ .style { color: #BF70A5; font-style: italic; } @{variable}:extend(.style) {} @variable: .selector;
使用下面命令编译less
lessc style.less style.css
得到css文件
/*style.css*/ .style, .selector { color: #BF70A5; font-style: italic; }
输出
执行以下步骤:
保存上面的HTML代码在 extend_syntax.html文件。
在浏览器中打开该HTML文件,得到如下输出显示。