SCSS 环形进度指示器问题

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

SCSS Circular Progress Incidator Issue

问题

我正在尝试将4步CSS进度指示器添加一个额外的步骤,使其成为一个5步进度指示器。以下是现有的代码。如何修改代码以实现这一目标?

.myact__progress-indicator {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid $twe-grey-lightest;
}

.myact__progress-indicator-progress {
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: 17px;
  clip: rect(0px, 34px, 34px, 17px);
  margin: -2px;

  &:before {
    position: absolute;
    display: block;
    content: '';
    width: 34px;
    height: 34px;
    background-color: $twe-green;
    border-radius: 17px;
    clip: rect(0px, 17px, 34px, 0px);
    transform: rotate(0deg);
  }
  &:after {
    position: absolute;
    display: block;
    content: '';
    width: 34px;
    height: 34px;
    background-color: $twe-green;
    border-radius: 17px;
    clip: rect(17px, 34px, 34px, 17px);
    transform: rotate(90deg);
  }
  &.p1 {
    &:before {
      transform: rotate(72deg);
    }
  }
  &.p2 {
    &:before {
      transform: rotate(144deg);
    }
  }
  &.p3 {
    clip: rect(0px, 34px, 34px, 0px);
    &:before {
      transform: rotate(144deg);
    }
    &:after {
      transform: rotate(90deg);
    }
  }
  &.p4 {
    clip: rect(0px, 34px, 34px, 0px);
    &:before {
      transform: rotate(216deg);
    }
    &:after {
      transform: rotate(72deg);
    }
  }
  &.p5 {
    clip: rect(0px, 34px, 34px, 0px);
    &:before {
      clip: rect(0px, 34px, 34px, 0px);
      transform: rotate(0deg);
    }
    &:after {
      display: none;
    }
  }
}

HTML:

<div class="myact__progress-indicator">
  <div class="myact__progress-indicator-progress p{{r.fields[6].value + 1}}"></div>
  <div class="myact__progress-indicator-inner">
    <span class="myact__progress-indicator-label">{{r.fields[6].value+1}}/5</span>
  </div>
</div>

P1和P2按预期工作,但在P3时出现问题,我尝试创建一个示例,但无法复制,希望我漏掉了一些明显的东西。

英文:

I am trying to add an extra stage to a 4-step CSS progress indicator and make it a 5-step progress indicator. The existing code is shown below. How can I modify the code to achieve this?

.myact__progress-indicator {
position:relative;
width:34px;
height:34px;
border-radius:50%;
border:2px solid $twe-grey-lightest;
}
.myact__progress-indicator-progress {
position:absolute;
width:34px;
height:34px;
border-radius:17px;
clip:rect(0px, 34px, 34px, 17px);
margin:-2px;
&amp;:before {
position:absolute;
display:block;
content:&#39;&#39;;
width:34px;
height:34px;
background-color:$twe-green;
border-radius:17px;
clip:rect(0px, 17px, 34px, 0px);
transform:rotate(0deg);
}
&amp;:after {
position:absolute;
display:block;
content:&#39;&#39;;
width:34px;
height:34px;
background-color:$twe-green;
border-radius:17px;
clip:rect(17px, 34px, 34px, 17px);
transform:rotate(90deg);
}
&amp;.p1 {
&amp;:before {
transform:rotate(72deg);
}
}
&amp;.p2 {
&amp;:before {
transform:rotate(144deg);
}
}
&amp;.p3 {
clip:rect(0px, 34px, 34px, 0px);
&amp;:before {
transform:rotate(144deg);
}
&amp;:after {
transform:rotate(90deg);
}
}
&amp;.p4 {
clip:rect(0px, 34px, 34px, 0px);
&amp;:before {
transform:rotate(216deg);
}
&amp;:after {
transform:rotate(72deg);
}
}
&amp;.p5 {
clip:rect(0px, 34px, 34px, 0px);
&amp;:before {
clip:rect(0px, 34px, 34px, 0px);
transform:rotate(0deg);
}
&amp;:after {
display:none;
}
}
}

HTML:

 &lt;div class=&quot;myact__progress-indicator&quot;&gt;
&lt;div class=&quot;myact__progress-indicator-progress p{{r.fields[6].value + 1}}&quot;&gt;&lt;/div&gt;
&lt;div class=&quot;myact__progress-indicator-inner&quot;&gt;
&lt;span class=&quot;myact__progress-indicator-label&quot;&gt;{{r.fields[6].value+1}}/5&lt;/span&gt;
&lt;/div&gt;
&lt;/div&gt;

P1 and P2 are working as expected but it starts to fall over at P3, I tried to create a fiddle but I'm unable to replicate, I'm hoping I missed something glaringly obvious.

SCSS 环形进度指示器问题

SCSS 环形进度指示器问题

SCSS 环形进度指示器问题

答案1

得分: 0

我只需要正确执行旋转操作,尽管从代码角度来看它的逻辑不像预期的那样工作,但渲染结果是符合预期的。

英文:

I just needed to do the rotations correctly, though it doesn’t work as logically expected from a code perspective it renders as expected.

huangapple
  • 本文由 发表于 2023年2月6日 15:31:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/75358466.html
匿名

发表评论

匿名网友

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

确定