[英]How do I use a material theme colors in my css in Angular2?
假设我需要使用css / sass类将mat-primary
颜色用作div
的背景,我该如何引用它? 我以为是这样的:
@import '~@angular/material/prebuilt-themes/deeppurple-amber.css';
.a-class{
background-color: $mat-primary;
}
但不幸的是失败了。
您必须先使用
@import '~@angular/material/prebuilt-themes/deeppurple-amber.css';
然后,您必须定义一个混合
@mixin primary-color($theme) {
$primary: map-get($theme, primary);
//Then you can use `mat-color` to get the `primary` color
.a-class {
background-color: mat-color($primary);
}
}
参考链接: 文档
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.