作者:世妖娆灬 | 来源:互联网 | 2023-01-12 14:36
我有很多麻烦,明显的解决方案不起作用或我做错了(可能是后者).
我想要设计我mat-menu
和我的风格,我mat-menu-item
试过这样做:
::ng-deep .mat-menu{
background-color:red;
}
但它不起作用,我的菜单看起来像这样(没有任何abornomal)
我也试过/深/但我知道不应该工作,实际上应该在Angular 4中折旧,但我做了测试,我不知道如何在这一点上设置元素的样式.
1> Z. Bagley..:
app.component.ts
import { Component, ViewEncapsulation ... } from '@angular/core';
@Component({
...
encapsulation: ViewEncapsulation.None
})
export class AppComponent {
constructor() { }
}
my.component.css
.mat-menu-content {
background-color: 'red' !important;
}
我通常使用它来设置高度和溢出css的样式,但一般的想法应该仍然代表背景颜色.请注意,可能有其他具有背景颜色的重叠div,但您应该能够通过它们的.mat-menu-
css 以这种方式访问它们并以相同的方式更改子项.