当前位置: 首页 > news >正文

纯CSS的华为充电动画,它来了

📢 鸿蒙专栏:想学鸿蒙的,冲

📢 C语言专栏:想学C语言的,冲

📢 VUE专栏:想学VUE的,冲这里

📢 Krpano专栏:想学Krpano的,冲

🔔 上述专栏,都在不定期持续更新中!!!!!!!!!!!!!

文章目录

✨ 关键点

✨ 效果演示

✨ 分析逻辑

 ✨ 下面附上完整代码


 

✨ 关键点

        拆解一下知识点,最主要的其实是用到了 filter: contrast() 以及 filter: blur() 这两个滤镜,可以很好的实现这种融合效果。

单独将两个滤镜拿出来,它们的作用分别是:

  • filter: blur() 给图像设置高斯模糊效果。
  • filter: contrast() 调整图像的对比度。

但是,当他们“合体”的时候,产生了奇妙的融合现象。

先来看一个简单的例子:

        仔细看两圆相交的过程,在边与边接触的时候,会产生一种边界融合的效果,通过对比度滤镜把高斯模糊的模糊边缘给干掉,利用高斯模糊实现融合效果。 

✨ 效果演示

✨ 分析逻辑

1、首先我们注意分析,这个效果到底需要怎样的结构去实现

        为了更好的看效果  我把所有的元素做了颜色区分,顶部其实就是两个圆利用border-radius去设置了圆角边框的弧度,下面呢?

        底部也是一个大圆,其中有很多很多个小圆,因为小圆要向上移动,实现效果,主要的代码如下:

@for $i from 0 through 15 { li:nth-child(#{$i}) {$width: 15 + random(15) + px;left: 15 + random(70) + px;top: 50%;transform: translate(-50%, -50%);width: $width;height: $width;animation: moveToTop #{random(6) + 3}s ease-in-out -#{random(5000)/1000}s infinite;}
}
@keyframes moveToTop {90% {opacity: 1;}100% {opacity: .1;transform: translate(-50%, -180px);}
}

注意:

  1. CSS本身不支持@for循环,这是一种Sass/SCSS的语法

 ✨ 下面附上完整代码

HTML:

<div class="g-container"><div class="g-number">98.7%</div><div class="g-contrast"><div class="g-circle"></div><ul class="g-bubbles"><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul></div>
</div>

SCSS

html,
body {width: 100%;height: 100%;display: flex;background: #000;overflow: hidden;
}
.g-number {position: absolute;width: 300px;top: 27%;text-align: center;font-size: 32px;z-index: 10;color: #fff;
}.g-container {position: relative;width: 300px;height: 400px;margin: auto;
}.g-contrast {filter: contrast(10) hue-rotate(0);width: 300px;height: 400px;background-color: #000;overflow: hidden;animation: hueRotate 10s infinite linear;
}.g-circle {position: relative;width: 300px;height: 300px;box-sizing: border-box;filter: blur(8px);&::after {content: "";position: absolute;top: 40%;left: 50%;transform: translate(-50%, -50%) rotate(0);width: 200px;height: 200px;background-color: #00ff6f;border-radius: 42% 38% 62% 49% / 45%;animation: rotate 10s infinite linear;}&::before {content: "";position: absolute;width: 176px;height: 176px;top: 40%;left: 50%;transform: translate(-50%, -50%);border-radius: 50%;background-color: #000;z-index: 10;}
}.g-bubbles {position: absolute;left: 50%;bottom: 0;width: 100px;height: 40px;transform: translate(-50%, 0);border-radius: 100px 100px 0 0;background-color: #00ff6f;filter: blur(5px);
}li {position: absolute;border-radius: 50%;background: #00ff6f;
}@for $i from 0 through 15 { li:nth-child(#{$i}) {$width: 15 + random(15) + px;left: 15 + random(70) + px;top: 50%;transform: translate(-50%, -50%);width: $width;height: $width;animation: moveToTop #{random(6) + 3}s ease-in-out -#{random(5000)/1000}s infinite;}
}@keyframes rotate {50% {border-radius: 45% / 42% 38% 58% 49%;}100% {transform: translate(-50%, -50%) rotate(720deg);}
}@keyframes moveToTop {90% {opacity: 1;}100% {opacity: .1;transform: translate(-50%, -180px);}
}@keyframes hueRotate {100% {filter: contrast(15) hue-rotate(360deg);}
}

注意注意注意:一定要用SCSS!!!!!!!!!!!!

注意注意注意:一定要用SCSS!!!!!!!!!!!!

注意注意注意:一定要用SCSS!!!!!!!!!!!!

我们改日再会

http://www.lryc.cn/news/267845.html

相关文章:

  • 在架构设计中,前后端分离有什么好处?
  • C语言中的结构体和联合体:异同及应用
  • 文件夹共享(普通共享和高级共享的区别)防火墙设置(包括了jdk安装和Tomcat)
  • ❀My排序算法学习之冒泡排序❀
  • 服务器数据恢复-raid6离线磁盘强制上线后分区打不开的数据恢复案例
  • Zookeeper在分布式命名服务中的实践
  • 说说 Spring Boot 实现接口幂等性有哪几种方案?
  • Dash中的callback的使用 多input 6
  • 平方矩阵()
  • git基本命令
  • GPU性能实时监测的实用工具
  • 概率论中的 50 个具有挑战性的问题 [第 6 部分]:Chuck-a-Luck
  • windows搭建MySQL主从补充说明
  • Python:GUI Tkinter
  • 制作一个可以离线安装的Visual Studio安装包
  • 机器学习——决策树(三)
  • 模型量化之AWQ和GPTQ
  • 一个简单的 HTTP 请求和响应服务——httpbin
  • 2024黑龙江省职业院校技能大赛暨国赛选拔赛应用软件系统开发赛项(高职组)赛题第3套
  • 云原生Kubernetes系列 | Kubernetes Secret及ConfigMap
  • dev express 15.2图表绘制性能问题
  • 单链表的创建,插入及删除(更新ing)
  • C#/WPF 播放音频文件
  • 如何使用宝塔面板+Discuz+cpolar内网穿透工具搭建可远程访问论坛服务
  • 【HBase】——简介
  • JAVA 有关PDF文件和图片文件合并并生产一个PDF
  • 八股文打卡day10——计算机网络(10)
  • Spring Boot学习:Flyway详解
  • Spark编程实验三:Spark SQL编程
  • 文献研读|Prompt窃取与保护综述