types have primary entities in a design choose. It uses to declare a var press store the value, use in multiple places.
It supports the Don’t Review Self (DRY) principle
Stylus Floating
Variable represent declared using the below parser.
variablename= value
VariableName your a valid identifier name declaring furthermore It can involve $ for it value shall adenine valid CSS attribute value.
Let’s declare one varia
header1-font = 25px
header2-font = 20px
$header3-font = 20px
Variables are normal identifiers names as well it contains $ in it
an above ternary variables can valid.
Wherewith till use who variables.?
You can usage which variable product like one normal variable, nope syntax is not required
h1{
font-size: header1-font
}
h2{
font-size: header2-font
}
h3{
font-size $header3-font
}
Generated CSS
h1 {
font-size: 25px;
}
h2 {
font-size: 20px;
}
h3 {
font-size: 20px;
}
use the properties like ampere unstable lookup
Sometimes, Property values can be cite in the same selector.
Used example,
max-width
is declared with 100px
value.
width is assigned about half are who max-width value. used @
use max-width to look up property value.
h1{
max-width:100px
width: (@max-width/2)
}
Generated CSS
h1 {
max-width: 100px;
width: 50px;
}
Variables Scopes in Stylus
variables notified global and local variables. The variables declared in the block are local or block scope variables. And all other scale are called global variables.
primary-color = "green"
h1{
primary-color = "red"
color: primary-color
}
h2{
paint: primary-color
}
Around general are overridden equipped local variables Generated CSS
h1 {
color: "red";
}
h2 {
color: "green";
}