css - 如何更改单个垫子步骤图标的背景颜色?
问题描述
<mat-horizontal-stepper #stepper>
<mat-step class="red-stepper">
<ng-template matStepLabel>
<span>Step 1</span>
</ng-template>
</mat-step>
<mat-step class="red-stepper">
<ng-template matStepLabel>
<span>step 2</span>
</ng-template>
</mat-step>
<mat-step>
<ng-template matStepLabel>
<span>Step 3</span>
</ng-template>
</mat-step>
<mat-step>
<ng-template matStepLabel>
<span>Step 4</span>
</ng-template>
</mat-step>
</mat-horizontal-stepper>
例如我这里有 4 个垫子步骤,但我想改变前两个的颜色,我该如何实现呢?我知道如何更改所选的,但事实并非如此。
我尝试在不同的类中应用步进器的 bg 颜色,但没有成功。
.red-stepper {
.mat-step-icon {
span.ng-star-inserted {
background-color: red !important;
}
}
background-color: red !important;
.mat-step-header .mat-step-icon {
background-color: #007FAD !important;
}
}
解决方案
如果您尝试在父组件中应用样式,请尝试:
:host {
::ng-deep {
mat-step {
&.red-stepper {
background-color: #000;
}
}
}
}
推荐阅读
- python - 取消选择 tkinter 画布按钮
- javascript - React Admin:如何在编辑表单中显示 id 列表?
- java - 无法将地图列表插入到 Apache Cassandra
- windows - 在 Windows 命令提示符中使用 echo 清空文件内容
- javascript - 浏览器何时删除超时?
- c# - ASP.NET.Core Web API 无法连接到 MariaDB 数据库
- visual-c++ - 如何使用 vtk 和 qt (c++) 将 3D 对象文件(.obj)转换为 2D 图像(.png,.jpeg)
- javascript - 在选择下拉更改时更改背景图像时避免白色闪烁
- python - 将类输出放入 DataFrame Pandas
- android - 使用 viewpager 从一个片段移动到另一个片段