如何使用labelPosition =“ bottom”更改物料步进线样式

时间:2019-06-10 13:38:22

标签: angular angular-material

我不会创建这样的样式:

enter image description here

我试图为已编辑步骤下的所有线条设置样式,但是在mat-step-headers之外还有其他线条。

::ng-deep .mat-horizontal-stepper-header {
    &[ng-reflect-state='edit'] + .mat-stepper-horizontal-line {
               border-top-width: 4px;
               border-top-color: blue;
    }
}

这是结果:

enter image description here

那么,我该怎么做?

2 个答案:

答案 0 :(得分:0)

标题中行的开头和结尾。您可以使用具有反射状态的此类。

.mat-stepper-label-position-bottom .mat-horizontal-stepper-header:not(:first-child)::before, [dir=rtl] .mat-stepper-label-position-bottom .mat-horizontal-stepper-header:not(:last-child)::before { 
  border-top-width: 4px;
  border-top-color: blue;
}

.mat-stepper-label-position-bottom .mat-horizontal-stepper-header:not(:last-child)::after, [dir=rtl] .mat-stepper-label-position-bottom .mat-horizontal-stepper-header:not(:first-child)::after {
  border-top-width: 4px;
  border-top-color: blue;
}

.mat-stepper-horizontal-line {
  border-top-width: 4px;
  border-top-color: blue;
}

答案 1 :(得分:0)

这是我的解决方案,也许会帮助某人:

scss

::ng-deep .mat-horizontal-stepper-header {
    height: 72px !important;
    padding: 0 10px !important;
    .mat-stepper-horizontal-line {
        top: 10px !important;
    }
    .mat-step-label {
        position: fixed;
        margin-top: 15px;
        width: 200px !important;
        white-space: pre-wrap;
        text-align: center;
    }
    &::before {
        width: 0;
    }
}
.selectedIndex0 {
}
@for $i from 1 through 10 {
    .selectedIndex#{$i} {
        @extend .selectedIndex#{$i - 1};
        ::ng-deep .mat-stepper-horizontal-line:nth-child(#{$i * 2}) {
            border-top-width: 4px !important;
            border-top-color: #3f51b5 !important;
        }
    }
}

并将[class]="'selectedIndex' + stepper.selectedIndex + ' mat-stepper-label-position-bottom'"添加到mat-horizontal-stepper标签