[英]getComputedStyle(element).getPropertyValue(“--varName”) does not work in firefox
Well, I want to use some css vars in my js code.好吧,我想在我的 js 代码中使用一些 css 变量。
Here is the part of my.css file and the.js code:这是my.css文件和.js代码的一部分:
const root = document.querySelector(":root"); const msgColor = getComputedStyle(root).getPropertyValue("--msg-color"); console.log(msgColor);
:root { --msg-color: crimson; --msg-text: floralwhite; }
The problem is that in chrome, safari and the new Edge I'm getting right the color value in my constant, but in firefox, doesn't working.问题是在 chrome 中,safari 和新的 Edge 我在我的常量中得到正确的颜色值,但在 firefox 中,不起作用。
Any ideas?有任何想法吗? Thanks.
谢谢。
It seems it was the version of firefox.似乎是 firefox 的版本。 It was the 68.xx Now with the 77.0.1 works fine.
它是 68.xx 现在与 77.0.1 工作正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.