博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CSS水滴融合效果
阅读量:2054 次
发布时间:2019-04-28

本文共 3485 字,大约阅读时间需要 11 分钟。

水滴融合效果

CSS

  • 首先设置一个容器,在容器里写三个div
  • 在把这个容器居中
.container {
display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #000; flex-direction: column; /* 使三个圆形垂直排列 */}
  • 设置水滴样式
.drop {
width: 100px; height: 100px; background-color: #fff; border-radius: 50%;}

效果如下

  • 通过绝对定位,使三个球重叠
.drop {
width: 100px; height: 100px; background-color: #fff; border-radius: 50%; position: absolute;}
  • 然后再设置三个球的位置,和过滤度
.drop {
width: 100px; height: 100px; background-color: #fff; border-radius: 50%; position: absolute; filter: blur(20px);}.drop:nth-child(2) {
transform: translateY(-80px);}.drop:nth-child(3) {
transform: translateY(-130px);}

如下效果

  • 在container里添加对比度来模糊边框 ,重新绘制出一个实边,从而达到融合到一起的效果
.container {
display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #000; flex-direction: column; /* 使三个圆形垂直排列 */ filter: contrast(30);}

效果如下

  • 在 HTML 中新增一个用来装水的容器
80%
  • CSS 样式如下
.collection {
width: 100px; height: 100px; background-color: #fff; border-radius: 50%; filter: blur(20px);}

效果如下

  • 编写CSS动画
@keyframes drop {
0% {
transform: scale(0.7) translateY(-600%); opacity: 0; } 50% {
transform: scale(0.4) translateY(-80%); opacity: 1; } 100% {
transform: scale(0.3) translateY(0px); }}
  • 给drop设置动画
.drop {
width: 100px; height: 100px; background-color: #fff; border-radius: 50%; position: absolute; filter: blur(20px); opacity: 0; animation: 2.5s drop linear infinite;}

即可达到以下效果

  • 给drop的另两个分别设置动画延迟
.drop:nth-child(2) {
animation-delay: 0.5s;}.drop:nth-child(3) {
animation-delay: 0.7s;}

效果如下

  • 编写collection的动画
@keyframes collection {
0% {
transform: scale(1) rotate(0deg); } 50% {
transform: scale(1.3) rotate(180deg); width: 90px; border-top-left-radius: 40%; border-bottom-left-radius: 45%; } 100% {
transform: scale(1) rotate(360deg); }}
.collection {
width: 100px; height: 100px; background-color: #fff; border-radius: 50%; filter: blur(20px); animation: 3s collection linear infinite;}

效果如下

完整代码:

      
Document
80%
body {
margin: 0; padding: 0;}.container {
display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #000; flex-direction: column; /* 使三个圆形垂直排列 */ filter: contrast(30);}.drop {
width: 100px; height: 100px; background-color: #fff; border-radius: 50%; position: absolute; filter: blur(20px); opacity: 0; animation: 2.5s drop linear infinite;}.drop:nth-child(2) {
animation-delay: 0.5s;}.drop:nth-child(3) {
animation-delay: 0.7s;}.collection {
width: 100px; height: 100px; background-color: #fff; border-radius: 50%; filter: blur(20px); animation: 3s collection linear infinite;}span {
position: absolute; font-family: Helvetica; font-size: 30px;}@keyframes drop {
0% {
transform: scale(0.7) translateY(-600%); opacity: 0; } 50% {
transform: scale(0.4) translateY(-80%); opacity: 1; } 100% {
transform: scale(0.3) translateY(0px); }}@keyframes collection {
0% {
transform: scale(1) rotate(0deg); } 50% {
transform: scale(1.3) rotate(180deg); width: 90px; border-top-left-radius: 40%; border-bottom-left-radius: 45%; } 100% {
transform: scale(1) rotate(360deg); }}

转载地址:http://zjclf.baihongyu.com/

你可能感兴趣的文章
【selenium】selenium ide的安装过程
查看>>
【手机自动化测试】monkey测试
查看>>
【英语】软件开发常用英语词汇
查看>>
Fiddler 抓包工具总结
查看>>
【雅思】雅思需要购买和准备的学习资料
查看>>
【雅思】雅思写作作业(1)
查看>>
【雅思】【大作文】【审题作业】关于同不同意的审题作业(重点)
查看>>
【Loadrunner】通过loadrunner录制时候有事件但是白页无法出来登录页怎么办?
查看>>
【Python】Python 读取csv的某行或某列数据
查看>>
【Loadrunner】平台1.9环境APP成功录制并调试成功后的脚本备份
查看>>
【Loadrunner】性能测试:通过服务器日志获取性能需求
查看>>
【Python】sasa版:文件中csv读取在写入csv读取的数据和执行是否成功。
查看>>
【loadrunner】【scorm学习】demo/test域上进行scorm脚本录制及回放成功脚本备份
查看>>
【Loadrunner】使用LoadRunner上传及下载文件
查看>>
【Loadrunner】使用LR录制HTTPS协议的三种方法
查看>>
【Python+Selenium】猪猪练习成功版:csv文件的输入和输出(运行环境:python3.5版本)...
查看>>
【python】BeautifulSoup的应用
查看>>
【Python】接口自动化测试-Fidder的使用(未完待续……)
查看>>
【Python】自动化测试框架-共通方法汇总
查看>>
【Python】if相关知识点
查看>>