Properties
描述 (Description)
变量可以由属性引用。
例子 (Example)
以下示例演示了LESS文件中properties引用的variables的使用 -
<html>
<head>
<link rel = "stylesheet" href = "style.css" type = "text/css" />
<title>LESS Variables Interpolation Properties</title>
</head>
<body>
<div class = "myclass">
<h2>Welcome to IoWiki</h2>
<p>LESS is a CSS pre-processor that enables customizable,
manageable and reusable style sheet for web site.</p>
</div>
</body>
</html>
现在创建文件style.less 。
style.less
@my-property: color;
.myclass {
background-@{my-property}: #81F7D8;
}
您可以使用以下命令将style.less编译为style.css -
lessc style.less style.css
执行上面的命令; 它将使用以下代码自动创建style.css文件 -
style.css
.myclass {
background-color: #81F7D8;
}
输出 (Output)
请按照以下步骤查看上述代码的工作原理 -
将上述html代码保存在less_variables_interpolation_properties.html文件中。
在浏览器中打开此HTML文件,将显示以下输出。