I am trying to use pure CSS to make radial progress bar with the background gradient. Depending on the class we provide .progress-47
or .progress-90
, the Sass for loop changes the behavior of our radial. I need to create the same effect but in counter-clockwise direction. The full code is available here in CodePen.
<div class="item progress-47">
<div class="radial-inner-bg"><span>47%</span></div>
</div>
<div class="item progress-33">
<div class="radial-inner-bg"><span>3/3</span></div>
</div>
<div class="item progress-95">
<div class="radial-inner-bg"><span>95%</span></div>
</div>
<div class="item progress-85">
<div class="radial-inner-bg"><span>85%</span></div>
</div>
$step: 1; // step of % for created classes
$loops: 100;
$increment: (360 / $loops);
$half: round($loops / 2);
@for $i from 0 through $loops {
.progress-#{$i*$step} {
@if $i < 50 {
$nextdeg: 90deg + ( $increment * $i );
background-image: linear-gradient(90deg, $light-gray 50%, transparent 50%, transparent), linear-gradient($nextdeg, $medium-yellow 50%, $light-gray 50%, $light-gray);
}
@else {
$nextdeg: -90deg + ( $increment * ( $i - $half ) );
background-image: linear-gradient($nextdeg, $medium-yellow 50%, transparent 50%, transparent), linear-gradient(270deg, $medium-yellow 50%, $light-gray 50%, $light-gray);
}
}
}