【问题标题】:How to change background color of a single mat step icon?如何更改单个垫子步骤图标的背景颜色?
【发布时间】:2019-06-20 02:19:53
【问题描述】:
 <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 个 mat-steps,但是我想改变前两个的颜色,我该如何实现呢?我知道如何更改所选的,但事实并非如此。

我尝试在不同的类中应用步进器的 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;
    }
}

【问题讨论】:

    标签: css angular angular-material


    【解决方案1】:

    如果您尝试在父组件中应用样式,请尝试:

    :host {
      ::ng-deep {
        mat-step {
          &.red-stepper {
            background-color: #000;
          }
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-12
      • 2020-08-03
      • 1970-01-01
      • 2020-08-21
      • 2018-01-13
      • 1970-01-01
      • 1970-01-01
      • 2020-02-17
      相关资源
      最近更新 更多