我正在尝试使用 CSS 变量,但发生了一些奇怪的事情。我这样声明变量:
:root {
--primary: '#fff';
--black: '#1b1f23';
--gray: '#586069';
--orange: '#f9826c';
--logo: '#fff';
--header: '#24292e';
--search: 'rgba(255; 255; 255; 0.13)';
}
Run Code Online (Sandbox Code Playgroud)
然后我像这样使用它们:
input {
background: var(--search);
}
Run Code Online (Sandbox Code Playgroud)
但由于某种原因,该样式没有被应用。当我将鼠标悬停在 Chrome Devtools 中的变量上时,它会显示正确的值,但它并不适用。
我对如何让它发挥作用非常迷失。
编辑:
我正在使用 React,所以这是渲染<input />
css ×1