我正在尝试在我的 Angular 应用程序中使用 css 变量, 在子组件中,它只是不工作。在浏览器的 Elements 工具(我使用的是 Chrome 最新版本)中,var() 不执行任何操作。例子:
CSS文件:
:root {
--width: 43.75%;
}
#content {
display: grid;
grid-template-columns: repeat(2, var(--width));
grid-auto-rows: 90%;
grid-gap: 3px;
align-content: center;
justify-content: center;
border: 2px solid black;
width: 400px;
height: 250px;
margin: 0 auto;
}
CSS 变量是否可以与 Angulat 一起使用? 谢谢
最佳答案
您的根选择器可能还会获得具有 Angular 组件 ID 的属性。
试试这个
::ng-deep :root {
--width: 43.75%;
}
关于javascript - CSS 变量和 Angular 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48396763/