【发布时间】:2018-08-03 20:54:25
【问题描述】:
我正在研究 mat-button-toggle-group,我通过覆盖 mat-button-toggle-checked 类来修改现有的 css,如下所示。现在,当我在按钮之间切换时,css 在我获得焦点之前无法工作,那是因为当单击的按钮处于焦点时添加了 2 个 cdk 类 'cdk-focused' 和 'cdk-program-focused' 。有什么方法可以使这些类禁用或使它们不应用或用相同的 mat-button-toggle-checked 覆盖它们?
<mat-button-toggle-group #group="matButtonToggleGroup" value="line">
<mat-button-toggle (click)="showLine()" value="line">Line</mat-button-toggle>
<mat-button-toggle (click)="showChart()" value="chart">Chart</mat-button-toggle>
</mat-button-toggle-group>
和css
mat-button-toggle-group {
border: solid 1px #d1d8de;
width:260px;
height:41px;
text-align: center;
.mat-button-toggle-checked{
background-color: #ffffff;
font-weight: bold;
}
.mat-button-toggle{
width:50%;
font-size: 15px;
}
}
【问题讨论】:
-
你摆脱了
cdk-focused和cdk-program-focused类吗? -
我的情况是一个垫子按钮打开垫子对话框时,对话框关闭时仍然有焦点。我通过在对话框关闭后自动调用按钮上的模糊来解决它 - github.com/angular/components/issues/…
标签: angular angular-material angular-cdk