样式材料滑块刻度

huangapple go评论67阅读模式
英文:

Style material slider ticks

问题

Using @angular/material 12.2

我想要为这些刻度添加一些样式(宽度和颜色)。我可以通过修改类.mat-slider-ticks和.mat-slider-ticks-container来改变刻度的高度,但对于宽度和颜色来说,这并不起作用。

从angular/components源代码中,我找到了这个:

.mat-slider-ticks {
@include vendor-prefixes.private-background-clip(content-box);
background-repeat: repeat;
box-sizing: border-box;
opacity: 0;
transition: opacity variables.$swift-ease-out-duration variables.$swift-ease-out-timing-function;
}

英文:

Using @angular /material 12.2

I want to add some style (width and color) to these ticks
I could change the tick height by modifying classes .mat-slider-ticks and .mat-slider-ticks-container, but it's not working for width and color.

From the angular/components source code, I found this :

.mat-slider-ticks {
@include vendor-prefixes.private-background-clip(content-box);
background-repeat: repeat;
box-sizing: border-box;
opacity: 0;
transition: opacity variables.$swift-ease-out-duration variables.$swift-ease-out-timing-function;
}

答案1

得分: 1

以下是翻译好的代码部分:

.custom-slider {
  .mat-mdc-slider .mdc-slider__tick-mark--active,
  .mat-mdc-slider .mdc-slider__tick-mark--inactive {
    height: 4px;
    width: 4px;
    background-color: red;
  }
}

如果您需要更多的翻译或有其他问题,请随时提出。

英文:

I was able to do this with the following rules. Note that I wrapped the mat-slider in a div with the custom-slider class as a way to avoid using !important. However, you can include just the inner rules in your global style if you don't mind the !important override.

.custom-slider {
  .mat-mdc-slider .mdc-slider__tick-mark--active,
  .mat-mdc-slider .mdc-slider__tick-mark--inactive {
    height: 4px;
    width: 4px;
    background-color: red;
  }
}

https://stackblitz.com/edit/angular-ygsg95?file=src%2Fstyles.scss

huangapple
  • 本文由 发表于 2023年4月6日 19:47:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/75949161.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定