简体   繁体   English

Angular 材质:如何更改垫子微调器路径的背景颜色

[英]Angular Material: How to change the background color for the mat spinner path

I created a mat progress spinner, changed the color of the stroke, but need to know how to change the CSS for the remaining stroke path我创建了一个垫子进度微调器,更改了描边的颜色,但需要知道如何更改剩余描边路径的 CSS

I tried changing the color but it changed the stroke color.我尝试改变颜色,但它改变了笔触颜色。 But I could not find anything related to path CSS.但我找不到与路径 CSS 相关的任何内容。 I could see circle is only getting generated when we use mat-progress-spinner我可以看到只有在我们使用 mat-progress-spinner 时才会生成圆圈

<mat-progress-spinner [color]="'orange'" [mode]="'determinate'" 
[diameter]="80" strokeWidth="5" [value]=" 70">
</mat-progress-spinner>
.mat-progress-spinner circle, .mat-spinner circle {
    stroke: green;
}

.mat-progress-spinner path, .mat-spinner path {
    stroke: red;
}

for example, value is 70 in the above example, then for 70 it should be mapped with orange color, need help on how to show different color for the remaining 30 value例如,上例中的值为 70,那么对于 70,它应该映射为橙色,需要帮助了解如何为剩余的 30 值显示不同的颜色

  • 70 - orange color 70 - 橙色
  • 30 - yellow color ( need solution for this ) 30-黄色(需要解决这个问题

The circle is created dynamically, so you wouldn't find a property to color the remaining portion (since that remaining portion is not painted at all - there is nothing there that we can change the color of);圆圈是动态创建的,因此您找不到为剩余部分着色的属性(因为根本没有绘制剩余部分 - 那里没有任何东西可以改变颜色);

But you can get the effect that you're looking for... you can do this by:但是您可以获得您正在寻找的效果......您可以通过以下方式做到这一点:

  • creating an image of the complete circle, placing it in your mat-card ... I took the following purple image创建完整圆圈的图像,将其放在您的mat-card中......我拍了以下紫色图像

在此处输入图像描述

  • Next, placing the mat-spinner on top of this static image via position:absolute接下来,通过position:absolutemat-spinner放置在此 static 图像之上

relevant HTML :相关HTML

<mat-card>
    <mat-card-content>
        <h2 class="example-h2">Result</h2>

        <img src='https://i.stack.imgur.com/aNUGr.png' alt='background'/>

        <mat-progress-spinner class="example-margin" [color]="color" [mode]="mode" [value]="value">
        </mat-progress-spinner>
    </mat-card-content>
</mat-card>

relevant CSS :相关CSS

mat-progress-spinner{    
  position: absolute;
  top: 56px;
  left: 19px;
}

circle{
  stroke-width: 11%;
}

complete working stackblitz here在这里完成工作堆栈闪电战

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM