gpt4 book ai didi

具有透明中间的 CSS 径向/圆形进度指示器

转载 作者:行者123 更新时间:2023-11-28 12:14:41 29 4
gpt4 key购买 nike

我想用 CSS 制作一个径向进度指示器,它的中间圆圈是透明的。看这里:http://codepen.io/geedmo/pen/InFfd – 这是我想要做的事情的完美示例,但中间 (.overlay) 具有覆盖更大圆圈的背景颜色。但是,我想让它透明(更大的圆圈中间也会有透明的)。怎么做?

<div class="wrap">

<div class="progress-radial progress-25">
<div class="overlay">25%</div>
</div>

<div class="progress-radial progress-50">
<div class="overlay">50%</div>
</div>

<div class="progress-radial progress-75">
<div class="overlay">75%</div>
</div>

<div class="progress-radial progress-90">
<div class="overlay">90%</div>
</div>

</div>

SASS:

// Colors
$barColor: tomato
$overlayColor: #fffde8
$backColor: #2f3439

@import url(http://fonts.googleapis.com/css?family=Noto+Sans)

body
padding: 30px 0
background-color: $backColor
font-family: 'Noto Sans', sans-serif

.wrap
width: 600px
margin: 0 auto

/* -------------------------------------
* Bar container
* ------------------------------------- */
.progress-radial
float: left
margin-right: 30px
position: relative
width: 100px
height: 100px
border-radius: 50%
border: 2px solid $backColor // remove gradient color


/* -------------------------------------
* Optional centered circle w/text
* ------------------------------------- */
.progress-radial .overlay
position: absolute
width: 60px
height: 60px
background-color: $overlayColor
border-radius: 50%
margin-left: 20px
margin-top: 20px
text-align: center
line-height: 60px
font-size: 16px

/* -------------------------------------
* Mixin for progress-% class
* ------------------------------------- */

$step: 5 // step of % for created classes

$loops: round(100 / $step)
$increment: 360 / $loops
$half: round($loops / 2)
@for $i from 0 through $loops
.progress-#{$i*$step}
@if $i < $half
$nextdeg: 90deg + ( $increment * $i )
border-image: linear-gradient(90deg, $backColor 50%, transparent 50%, transparent), linear-gradient($nextdeg, $barColor 50%, $backColor 50%, $backColor)
@else
$nextdeg: -90deg + ( $increment * ( $i - $half ) )
border-image: linear-gradient($nextdeg, $barColor 50%, transparent 50%, transparent), linear-gradient(270deg, $barColor 50%, $backColor 50%, $backColor)

这是我想要得到的结果:

result

最佳答案

html代码:

<div class="wrapper">
<div class="pie spinner lightBlue"></div>
<div class="pie filler lightBlue"></div>
<div class="mask"></div>
</div>

CSS 代码:

body {
background-color: #f3f3f4;
}

.lightBlue {
border: 10px solid #a8d2d2;
}

.wrapper {
width: 250px;
height: 250px;
margin: 10px auto;
position: relative;
background: white;
background-color: #f3f3f4;
-webkit-transition: width 0.5s, height 0.5s;
transition: width 0.5s, height 0.5s;
-webkit-animation: finalRota 2s 10s linear forwards;
animation: finalRota 2s 10s linear forwards;
}

.wrapper .pie {
width: 50%;
height: 100%;
position: absolute;
background-color: radial-gradient(left center, circle, #00ccff 0px, #000088 100%);
-webkit-transform-origin: 100% 50%;
-ms-transform-origin: 100% 50%;
transform-origin: 100% 50%;
}

.wrapper .spinner {
border-radius: 100% 0 0 100% / 50% 0 0 50%;
z-index: 200;
background-color: radial-gradient(right center, circle, #00ccff 0px, #000088 100%);
border-right: none;
-webkit-animation: rota 10s linear forwards;
animation: rota 10s linear forwards;
}

.wrapper .filler {
border-radius: 0 100% 100% 0 / 0 50% 50% 0;
left: 50%;
border: 10px solid #8dbdbb;
opacity: 0;
z-index: 100;
border-left: none;
-webkit-animation: fill 10s steps(1, end) forwards;
animation: fill 10s steps(1, end) forwards;
}

.wrapper .mask {
width: 50%;
height: 100%;
position: absolute;
background: inherit;
opacity: 1;
z-index: 300;
-webkit-animation: mask 10s steps(1, end) forwards;
animation: mask 10s steps(1, end) forwards;
}

@-webkit-keyframes opoFinalRota {
100% {
-webkit-transform: rotate(30deg);
-ms-transform: rotate(30deg);
transform: rotate(30deg);
}
}

@keyframes opoFinalRota {
100% {
-webkit-transform: rotate(30deg);
-ms-transform: rotate(30deg);
transform: rotate(30deg);
}
}
@-webkit-keyframes rota {
0% {
-webkit-transform: rotate(300deg);
transform: rotate(300deg);
}
100% {
-webkit-transform: rotate(60deg);
transform: rotate(60deg);
}
}
@keyframes rota {
0% {
-webkit-transform: rotate(300deg);
transform: rotate(300deg);
}
100% {
-webkit-transform: rotate(60deg);
transform: rotate(60deg);
}
}
@-webkit-keyframes mask {
0% {
opacity: 1;
}
50%, 100% {
opacity: 0;
}
}
@keyframes mask {
0% {
opacity: 1;
}
50%, 100% {
opacity: 0;
}
}
@-webkit-keyframes fill {
0% {
opacity: 0;
}
50%, 100% {
opacity: 1;
}
}
@keyframes fill {
0% {
opacity: 0;
}
50%, 100% {
opacity: 1;
}
}

和一个演示:http://jsfiddle.net/usrs01ye/2/

enter image description here

关于具有透明中间的 CSS 径向/圆形进度指示器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24785707/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com