📜  LESS变量

📅  最后修改于: 2021-01-06 04:40:42             🧑  作者: Mango

较少的变量

较少的变量用符号@定义,并且值在变量中用冒号(:)分配。变量实际上是“常量”,因为它们只能定义一次。

请参阅以下示例:

@nice-blue: #5B83AD;
@light-blue: @nice-blue + #111;
#header {
  color: @light-blue;
} 

在这里,蓝色和浅蓝色是变量,并为其分配了值。

编译后,生成的CSS:

#header {
  color: #6c94be;
}

Less变量列表:

Index Variable Explanation
1) Overview A variable can be used to avoid the repetition of same value occurred many times.
2) Variable Interpolation You can use variables on other places like selector names, property names, URLs and @import statements.
3) Variable Names A variable can be defined with a variable name containing a value.
4) Lazy Loading Lazy Loading specifies that you can use the variables even though they are not declared yet.
5) Default Variables Defaulr variable facilitates you to set a variable only when it?s not already set. It is not a necessary feature because variables can be easily overridden by defining them afterwards.