scss. constant
时间: 2023-10-21 08:05:26 浏览: 34
SCSS (Sass) constants are variables that hold a fixed value that can be reused throughout the stylesheet. They are declared using the `$` symbol followed by the variable name and the value assigned to it.
For example:
```
$primary-color: #007bff;
$secondary-color: #6c757d;
.btn-primary {
background-color: $primary-color;
color: #fff;
}
.btn-secondary {
background-color: $secondary-color;
color: #fff;
}
```
In this example, `$primary-color` and `$secondary-color` are declared as constants holding the values `#007bff` and `#6c757d`, respectively. These constants are then used in the styles for the `.btn-primary` and `.btn-secondary` classes. If we want to change the color of all primary buttons, we only need to update the value of `$primary-color` in one place, and the change will be reflected throughout the stylesheet.