我<md-input-container>在Angular组件中使用Material 2 .我想覆盖其中一个类,例如.mat-input-wrapperAngular Material中定义的类.但我想仅覆盖该组件,并且覆盖不应影响页面中的其他组件.
我为我的应用程序使用了多个菜单,并为此使用了角形材料垫菜单组件。我可以通过在菜单原始类的全局 css 文件中编写 css 代码来更改所有菜单的样式。但是当我想使用 .custom-class-name .original-material-class-name{} 添加一些特定样式到其中之一时,它不会将这些样式应用于该菜单。
\n\n这是 stackblitz 中的整个应用程序:
\n\nheader.component.html:
\n\n<div>\n<a mat-button class="theme-menu-toggle-button" *ngIf="!menuAvailable" \n(click)="changeSidenavMode(!mode)">\n <mat-icon>menu</mat-icon>\n</a>\n<a href="#" fxHide.lt-md fxShow.gt-sm class="theme-user" mat-button \n[matMenuTriggerFor]="menu">\n <img src="assets/images/user.png" class="theme-profile-image rounded-circle">\n <span class="theme-profile-title">\xd9\x86\xd8\xa7\xd9\x85 \xd9\x86\xd8\xa7\xd9\x85\xe2\x80\x8c\xd8\xae\xd8\xa7\xd9\x86\xd9\x88\xd8\xa7\xd8\xaf\xda\xaf\xdb\x8c</span>\n</a>\n<mat-menu #menu="matMenu" class="profile-menu">\n <button mat-menu-item *ngFor="let option of profileOptions">\n <mat-icon>{{option.icon}}</mat-icon>\n <span>{{option.title}}</span>\n </button>\n</mat-menu>\nRun Code Online (Sandbox Code Playgroud)\n\n样式.css:
\n\n.profile-menu .cdk-overlay-pane::before{\n width: 0;\n height: 0;\n border-left: 8px solid transparent;\n border-right: 8px solid transparent;\n border-bottom: 15px solid #5E35B1;\n content: " ";\n position: absolute;\n top: 10px !important;\n animation: fadeInRightBig 0.75s;\n}\nRun Code Online (Sandbox Code Playgroud)\n