您当前的位置:首页 >> 设计动态

纯 CSS 实现十个非常Nice的Loading 精准度

2023-04-28 12:16:13

olute; top: 50%; left:100%; transform: translateY(-50%); width:10px; height: 10px; border: 2px solid #000;}@keyframes p5 { 100% {background-size:120%}}

原作者对 .progress-5::before 假元素意味着如下:

.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 是薄膜,同等 transparent

6、可视调用

这起名起得有些不广为人知,不过不重要,读者看图共存理解。

.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; 右边内缩 100%,所以在 keyframes 一小需要将 inset 设置为 0。

7、珠链调用 .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%}}

遮罩 -webkit-mask 中都 radial-gradient 是将宽度四等份,每份以最小 closest-side 的边为高约画圆。

8、斑马线调用 .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%}}

对 linear-gradient 描绘的角度来作优化,再行以致于蒙版。

9、水花调用 .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 画出水平面的瞬时,就三个圆。var(;还有r1) 单独调用下定义好的属性值。技能 get ...

10、频率调用 .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%}}

用 repeating-radial-gradient 步骤画出网状的蒙版遮罩。radial-gradient 从下方向内圆形渐变缓冲。

Uha,看了这么多骚操作,你学废了吗?

简介和后北京话文中:10 CSS-only loaders ready to use![2]简介资料

[1]

T. Afif:

[2]

10 CSS-only loaders ready to use!:

#头条创作女子组#

妇产科
江中多维元素片
闹肚子怎么办
早期肝硬化有什么症状
拉肚子可以吃蒙脱石散吗
相关阅读
友情链接