[英]CSS Variables vs CSS Modules @value
I was wondering what exactly is the difference between the css function var(--red) and @value red from css modules. 我想知道css函数var(-red)和css模块中的@value red之间到底有什么区别。
CSS Modules Example: CSS模块示例:
@value red from "./color.m.css";
.background {
background-color: red;
}
CSS Var() Example: CSS Var()示例:
@import "./color.m.css";
.background {
background-color: var(--red);
}
Is there an advantage using one of them? 使用其中之一是否有优势?
Thanks in advance for helping me out! 在此先感谢您对我的帮助!
CSS modules @value is CSS模块@value是
CSS Var() is CSS Var()是
As of i know modules are very useful as they can import any where they want and can be used.but variables can only be used inside page with global and inline scope. 就我所知,模块非常有用,因为它们可以导入所需的任何位置并可以使用。但是变量只能在具有全局范围和内联范围的页面内使用。
module and css variable are incomparable as i think so. 模块和css变量是我无法比拟的。
please check this link for more reference. 请检查此链接以获取更多参考。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.