根据主体类别更改所有变量值 [英] Change all variable value based on body class

查看:81
本文介绍了根据主体类别更改所有变量值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在基于主题的本地化。为此,我要在每个本地化的身体标签上上课。
我需要根据该类更改所有变量的值
为了进一步理解

I am working on theme based localisation. For that I am getting class on body tag for each localisation. I need to change all variables value based on that class For more Understanding

$a: #000;
$b= Arial;

if body has class Australia then
$a: #ff0000;
$b: 'Roboto';

请仅通过scss禁止js代码

Please no js code only by scss

推荐答案

使用@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';
}

这篇关于根据主体类别更改所有变量值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆