简体   繁体   English

如何覆盖 fonts 的 scss 变量?

[英]How to override scss variables for fonts?

Is there any way to override scss variables used for fonts.有没有办法覆盖用于 fonts 的scss 变量 i have used font variables across the website and now i need to change the font specifically for a localized website .我已经在整个网站上使用了字体变量,现在我需要专门为本地化网站更改字体。

i need to override using :lang attribute in html.我需要使用 html 中的:lang属性覆盖。 is there any way to override variables or any implementation idea to achieve this.有没有办法覆盖变量或任何实现想法来实现这一点。 my idea is to achieve something like this.我的想法是实现这样的目标。 if this is achievable by any means we don't require to override in all places where this fonts are declared.如果这可以通过任何方式实现,我们不需要在声明此 fonts 的所有地方覆盖。

$primary-font: 'Roboto';
:lang('fr') { $primary-font: 'locator' }

Added codepen of what i am trying to solve添加了我要解决的问题的代码笔

I haven't been able to test this but given it compiles to a CSS key value pair can you use我无法对此进行测试,但鉴于它编译为 CSS 键值对,您可以使用

'locator !important'

Not ideal coding I know but it might work我知道不是理想的编码,但它可能有效

You have to give the newly assigned value as font-family as follow.您必须将新分配的值作为 font-family 如下所示。

 $primary-font: 'Locator'; * { font-family: $primary-font; } [lang="fr"] { $primary-font: 'oswald'; font-family: $primary-font; }
 <div lang="fr"> <p>test frace</p> </div> <p>test normal</p>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM