我创建了一个垫子工具栏,并添加了垫子按钮,使用
@import '~@angular/material/prebuilt-themes/indigo-pink.css';
垫子按钮的字体颜色保持为灰色而不是白色
这就是它看起来的样子
下面是component.html代码
<mat-toolbar-row>
<div fxHide.gt-xs>
<button mat-button>
<mat-icon (click)="sidenav.toggle()">menu</mat-icon>
menu
</button>
</div>
<div class="icon-center" fxLayout="column" fxLayoutAlign="center center" fxFlex >
BuySell
</div>
<div fxFlex fxLayout fxLayoutAlign="flex-end" fxHide.xs>
<button mat-button *ngIf="!signedIn" routerLink="/auth"><span class="label"> Log in </span></button>
<button mat-button *ngIf="!(path == '/home')" routerLink="/home"><span class="label"> Home </span>
</button>
<button mat-button *ngIf="signedIn" routerLink="/demo">
<span class="label" > Demo </span>
</button>
<button mat-button *ngIf="signedIn" color="accent" routerLink="/stocks">
<span class="label" > Stocks </span>
</button>
<button mat-button *ngIf="signedIn" color="accent" routerLink="/">
<span class="label" (click)="logOut()">Log Out</span>
</button>
</div>
</mat-toolbar-row>
这是component.ts
export class HeaderComponent implements OnInit {
signedIn: boolean;
public path = '' ;
@Output() public sidenavToggle = new EventEmitter();
constructor( private amplifyService: AmplifyService,
private router: Router) {
this.amplifyService.authStateChange$
.subscribe(authState => {
this.signedIn = authState.state === 'signedIn';
});
this.path = router.url;
}
public onToggleSidenav = () => {
this.sidenavToggle.emit();
}
}
发布于 2019-07-17 09:54:32
您的mat-button
的CSS属性很可能会被类.label
的跨度覆盖。
如果其中没有什么重要的东西,您可能希望完全删除.label
类,或者检查.label
类是否包含可能覆盖了mat-button
默认样式的任何CSS属性(例如color
)。
<mat-toolbar color="primary">
<mat-toolbar-row>
<span>BuySell</span>
<span class="example-spacer"></span>
<button mat-button routerLink="/auth">
<span>Log in</span>
</button>
<button mat-button routerLink="/stocks">
Stocks
</button>
</mat-toolbar-row>
</mat-toolbar>
另外,我注意到你的一些按钮是用accent
颜色设计的。请注意,对于这些按钮,按钮中的文本标签将是红色的,而不是白色的。
否则,您的工具栏应该工作得很好,如此demo所示。
发布于 2019-07-17 10:09:38
你可以用.label类CSS覆盖你的mat按钮CSS。将CSS更改为:
:host ::ng-deep .mat-button {
color: #FFF !important;
}
发布于 2019-07-17 09:49:26
尝试使用CSS来更改它:
.mat-button {
color: #FFF;
opacity: 1;
}
https://stackoverflow.com/questions/57072676
复制