我正在研究基于主题的本地化。为此,我正在为每个本地化的 body 标签上类(class)。 我需要根据该类更改所有变量值 更多了解
$a: #000;
$b= Arial;
if body has class Australia then
$a: #ff0000;
$b: 'Roboto';
请不要仅使用scss编写js代码
最佳答案
使用 @import 和 !default 变量
// ––––––––––––––––––––––––––––––––––––––
// _style.scss
// underscore added to prevent compilation
// ––––––––––––––––––––––––––––––––––––––
$color : red !default;
$font-family: Arial !default;
.foo { color: $color; }
.bar { font-family: $font-family; }
// ––––––––––––––––––––––––––––––––––––––
// style.scss (compile file)
// ––––––––––––––––––––––––––––––––––––––
// redefine variables
$color: blue;
$font-family: Roboto;
// add wrapper if needed (will be added to all selectors)
.australia {
@import '_style.scss';
}
关于css - 根据 body 类别更改所有变量值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42250583/