Vea los diez efectos de T. Afif en Twitter . Loading
Como se muestra arriba.
Sí, es genial, es muy práctico, así que lo grabé.
Para garantizar un funcionamiento normal, primero estipulamos lo siguiente:
* {
box-sizing: border-box;
}
复制代码
1. Carga suave
<div class="progress-1"></div>
复制代码
.progress-1 {
width:120px;
height:20px;
background:
linear-gradient(#000 0 0) 0/0% no-repeat
#ddd;
animation:p1 2s infinite linear;
}
@keyframes p1 {
100% {background-size:100%}
}
复制代码
linear-gradient(#000 0 0)
Puede comprenderlinear-gradient(#000 0 100%)
que si no está familiarizado con él, copielinear-gradient(#000 0 50%, #f00 50% 0)
y reemplace la pieza original y ejecútela. Si te sienteslinear-gradient(#000 0 0)
incómodo , escríbelo directamente#000
.0/0%
background-position: 0;/background-size: 0;
es la abreviatura de .
2. Cargar paso a paso
<div class="progress-2"></div>
复制代码
.progress-2 {
width:120px;
height:20px;
border-radius: 20px;
background:
linear-gradient(orange 0 0) 0/0% no-repeat
lightblue;
animation:p2 2s infinite steps(10);
}
@keyframes p2 {
100% {background-size:110%}
}
复制代码
steps(10)
esstep(10, end)
una abreviatura de , lo que indica que no estaba al principio, por lo que está el procesamiento del punto 2100% {background-size:110%}
Agreguestep
un porcentaje de , arribastep
es10
, entonces sí100% + (1/10)*100% = 110%
3. Carga de franjas
<div class="progress-3"></div>
复制代码
.progress-3 {
width:120px;
height:20px;
border-radius: 20px;
background:
repeating-linear-gradient(135deg,#f03355 0 10px,#ffa516 0 20px) 0/0% no-repeat,
repeating-linear-gradient(135deg,#ddd 0 10px,#eee 0 20px) 0/100%;
animation:p3 2s infinite;
}
@keyframes p3 {
100% {background-size:100%}
}
复制代码
repeating-linear-gradient(135deg,#ddd 0 10px,#eee 0 20px) 0/100%;
Dibuje una franja de cebra gris, repeating-linear-gradient(135deg,#f03355 0 10px,#ffa516 0 20px) 0/0% no-repeat
que es la franja cargada por la barra de progreso.
4. Carga de línea punteada
<div class="progress-4"></div>
复制代码
.progress-4 {
width:120px;
height:20px;
-webkit-mask:linear-gradient(90deg,#000 70%,#0000 0) 0/20%;
background:
linear-gradient(#000 0 0) 0/0% no-repeat
#ddd;
animation:p4 2s infinite steps(6);
}
@keyframes p4 {
100% {background-size:120%}
}
复制代码
-webkit-mask
Hay un valor por defecto repeat
, de lo contrario la máscara no tendrá cinco.
5. Carga de la batería
<div class="progress-5"></div>
复制代码
.progress-5 {
width:80px;
height:40px;
border:2px solid #000;
padding:3px;
background:
repeating-linear-gradient(90deg,#000 0 10px,#0000 0 16px)
0/0% no-repeat content-box content-box;
position: relative;
animation:p5 2s infinite steps(6);
}
.progress-5::before {
content:"";
position: absolute;
top: 50%;
left:100%;
transform: translateY(-50%);
width:10px;
height: 10px;
border: 2px solid #000;
}
@keyframes p5 {
100% {background-size:120%}
}
复制代码
El autor original implementa el .progress-5::before
pseudoelemento de la siguiente manera:
.progress-5::before {
content:"";
position: absolute;
top:-2px;
bottom:-2px;
left:100%;
width:10px;
background:
linear-gradient(
#0000 calc(50% - 7px),#000 0 calc(50% - 5px),
#0000 0 calc(50% + 5px),#000 0 calc(50% + 7px),#0000 0) left /100% 100%,
linear-gradient(#000 calc(50% - 5px),#0000 0 calc(50% + 5px),#000 0) left /2px 100%,
linear-gradient(#0000 calc(50% - 5px),#000 0 calc(50% + 5px),#0000 0) right/2px 100%;
background-repeat:no-repeat;
}
复制代码
#0000 es transparente, igual transparente
6. Carga en línea
Este nombre es un poco inapropiado, pero no es importante, y los lectores lo entenderán naturalmente al mirar la imagen.
<div class="progress-6"></div>
复制代码
.progress-6 {
width:120px;
height:22px;
border-radius: 20px;
color: #514b82;
border:2px solid;
position: relative;
}
.progress-6::before {
content:"";
position: absolute;
margin:2px;
inset:0 100% 0 0;
border-radius: inherit;
background: #514b82;
animation:p6 2s infinite;
}
@keyframes p6 {
100% {inset:0}
}
复制代码
inset:0 100% 0 0;
La derecha está sangrada 100%
, por lo que en la keyframes
sección que debe inset
establecer en 0
.
7. Carga de cadena de cuentas
<div class="progress-7"></div>
复制代码
.progress-7 {
width:120px;
height:24px;
-webkit-mask:
radial-gradient(circle closest-side,#000 94%,#0000) 0 0/25% 100%,
linear-gradient(#000 0 0) center/calc(100% - 12px) calc(100% - 12px) no-repeat;
background:
linear-gradient(#25b09b 0 0) 0/0% no-repeat
#ddd;
animation:p7 2s infinite linear;
}
@keyframes p7 {
100% {background-size:100%}
}
复制代码
En la máscara -webkit-mask
, radial-gradient
el ancho se divide en cuatro partes iguales, y cada parte dibuja closest-side
un como diámetro.
8. Carga cebra
<div class="progress-8"></div>
复制代码
.progress-8 {
width:60px;
height:60px;
border-radius: 50%;
-webkit-mask:linear-gradient(0deg,#000 55%,#0000 0) bottom/100% 18.18%;
background:
linear-gradient(#f03355 0 0) bottom/100% 0% no-repeat
#ddd;
animation:p8 2s infinite steps(7);
}
@keyframes p8 {
100% {background-size:100% 115%}
}
复制代码
Ajuste el ángulo del linear-gradient
dibujo y agregue una máscara.
9. Carga de la columna de agua
<div class="progress-9"></div>
复制代码
.progress-9 {
--r1: 154%;
--r2: 68.5%;
width:60px;
height:60px;
border-radius: 50%;
background:
radial-gradient(var(--r1) var(--r2) at top ,#0000 79.5%,#269af2 80%) center left,
radial-gradient(var(--r1) var(--r2) at bottom,#269af2 79.5%,#0000 80%) center center,
radial-gradient(var(--r1) var(--r2) at top ,#0000 79.5%,#269af2 80%) center right,
#ccc;
background-size: 50.5% 220%;
background-position: -100% 0%,0% 0%,100% 0%;
background-repeat:no-repeat;
animation:p9 2s infinite linear;
}
@keyframes p9 {
33% {background-position: 0% 33% ,100% 33% ,200% 33% }
66% {background-position: -100% 66%,0% 66% ,100% 66% }
100% {background-position: 0% 100%,100% 100%,200% 100%}
}
复制代码
radial-gradient
Dibuja la fluctuación del plano horizontal, solo tres círculos. var(--r1)
Llame directamente al valor de propiedad definido. habilidades get
...
10. Carga de señal
<div class="progress-10"></div>
复制代码
.progress-10 {
width:120px;
height:60px;
border-radius:200px 200px 0 0;
-webkit-mask:repeating-radial-gradient(farthest-side at bottom ,#0000 0,#000 1px 12%,#0000 calc(12% + 1px) 20%);
background:
radial-gradient(farthest-side at bottom,#514b82 0 95%,#0000 0) bottom/0% 0% no-repeat
#ddd;
animation:p10 2s infinite steps(6);
}
@keyframes p10 {
100% {background-size:120% 120%}
}
复制代码
Usa el repeating-radial-gradient
método para dibujar una máscara en forma de anillo. radial-gradient
Relleno degradado circular de abajo hacia arriba.
Uha, ¿has perdido tus estudios después de ver tantas operaciones llamativas?