本篇文章主要介绍用CSS3实现的水波扩散涟漪,圆波扩散,光圈扩散,雷达波向外散发动画。

预期效果应该是这样:,其实应该比这个更优美,因为设计师提供的gif出现透明度丢失问题,所以建议用css3实现。

一、明确参数

1、半径

30,42,54
2、透明度

100%,50%,20%
3、颜色

#fb7070

二、实现方案

1、border-width + animation

<div parent="box">
    <a id="J_dot"></a>
</div>
div[parent="box"] {
  position: relative;
  margin:50px auto;
  width:54px;
  height: 54px;
}
#J_dot{
  float: left;
  width: 54px;
  height: 54px;
  box-sizing: border-box;
  border-style:double;
  border-color: #fb7070;
  border-radius: 100%;
  animation: circleAnimation 1s infinite alternate;
}

@keyframes circleAnimation {
  from {
     border-width:;
  }
  to {
     border-width:27px;
  }
}

@-webkit-keyframes circleAnimation {
  from {
    border-width:;
  }
  to {
    border-width:27px;
  }
}

太假了,整个动画一直固定在大圆圈内,内圆圈似乎在来回放大缩小,离期望值太远!

2、box-shadow + background-color +animation

<div parent="box">
  <div class="outer-circle">
    <div class="inner-circle"></div>
  </div>
</div>
div[parent="box"] {
  position:relative;
  margin:50px auto;
  width:54px;
  height:54px;
}
.outer-circle {
  animation: circleAnimationOut 1.5s cubic-bezier(0.165, 0.84, 0.44, 1);
}
.inner-circle {
  animation: circleAnimationIn 1.5s cubic-bezier(0.165, 0.84, 0.44, 1);
}
.outer-circle, .inner-circle {
  position: absolute;
  z-index:;
  width: 30px;
  height: 30px;
  background: transparent;
  border-radius: 100%;
  animation-iteration-count: infinite;
}

@keyframes circleAnimationOut {
  0% {
    box-shadow: 0 0 0 0px rgba(251, 112, 112, 0.5);
  }
  100% {
    box-shadow: 0 0 0 24px rgba(251, 112, 112, 0.2);
  }
}
@keyframes circleAnimationIn {
  0% {
    box-shadow: 0 0 0 0px rgba(251, 112, 112, 0.5);
    background-color: rgba(251, 112, 112, 1);
  }
  100% {
    box-shadow: 0 0 0 12px rgba(251, 112, 112, 0.5);
    background-color: rgba(251, 112, 112, 1);
  }
}

中间实心圆貌似没怎么动啊,效果还凑合。

3、box-shadow + transform +animation

<div parent="box">
  <div class="dot"></div>
  <div class="inner-circle"></div>
  <div class="outer-circle"></div>
</div>
@keyframes circleAnimationIn {
  0% {
    transform: scale(0.3);
    -webkit-transform: scale(0.3);
    opacity: 0.0;
  }
  25% {
    transform: scale(0.3);
    -webkit-transform: scale(0.3);
    opacity: 0.1;
  }
  50% {
    transform: scale(0.5);
    -webkit-transform: scale(0.5);
    opacity: 0.3;
  }
  75% {
    transform: scale(0.8);
    -webkit-transform: scale(0.8);
    opacity: 0.5;
  }
  100% {
    transform: scale(1);
    -webkit-transform: scale(1);
    opacity: 0.0;
  }
}
@keyframes circleAnimationOut {
  0% {
    transform: scale(0.3);
    -webkit-transform: scale(0.3);
    opacity: 0.0;
  }
  25% {
    transform: scale(0.3);
    -webkit-transform: scale(0.3);
    opacity: 0.1;
  }
  50% {
    transform: scale(0.3);
    -webkit-transform: scale(0.3);
    opacity: 0.3;
  }
  75% {
    transform: scale(0.5);
    -webkit-transform: scale(0.5);
    opacity: 0.5;
  }
  100% {
    transform: scale(0.8);
    -webkit-transform: scale(0.8);
    opacity: 0.0;
  }
}
div[parent="box"] {
  position: relative;
  margin: 50px auto;
  width: 54px;
  height: 54px;
}

/* 保持大小不变的小圆点 */
.dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 20px;
  margin-left: -9px;
  margin-top: -9px;
  -webkit-border-radius: 50%;
  -moz-border-radius: 50%;
  border-radius: 50%;
  background-color: #fb7070; /* 实心圆 ,如果没有这个就是一个小圆圈 */
  z-index:;
}

/* 产生动画(向外扩散变大)的圆圈 第一个圆 */
.inner-circle {
  position: absolute;
  z-index:;
  width: 54px;
  height: 54px;
  -webkit-border-radius: 50%;
  -moz-border-radius: 50%;
  border-radius: 50%;
  border: 1px solid #fb7070;
  -webkit-animation: circleAnimationIn 2s ease-out;
  -moz-animation: circleAnimationIn 2s ease-out;
  animation: circleAnimationIn 2s ease-out;
  -webkit-animation-iteration-count: infinite;
  -moz-animation-iteration-count: infinite;
  animation-iteration-count: infinite;
  box-shadow: 1px 1px 30px #fb7070;
}

/* 产生动画(向外扩散变大)的圆圈 第二个圆 */
.outer-circle {
  position: absolute;
  z-index:;
  width: 54px;
  height: 54px;
  -webkit-border-radius: 50%;
  -moz-border-radius: 50%;
  border-radius: 50%;
  border: 1px solid #fb7070;
  -webkit-animation: circleAnimationOut 2s ease-out;
  -moz-animation: circleAnimationOut 2s ease-out;
  animation: circleAnimationOut 2s ease-out;
  -webkit-animation-iteration-count: infinite;
  -moz-animation-iteration-count: infinite;
  animation-iteration-count: infinite;
  box-shadow: 1px 1px 30px #fb7070;
}

CSS3组件化之圆波扩散的更多相关文章

  1. CSS3组件化之ios版菊花loading

    <div class="juhua-loading"> <div class="jh-circle1 jh-circle-ios">&l ...

  2. CSS3组件化之菊花loading

    <div class="juhua-loading"> <div class="jh-circle"></div> < ...

  3. CSS3组件化之单线箭头

    <div class="parent-box"> <div class="top-arrow"></div> <div ...

  4. vue.js组件化开发实践

    前言 公司目前制作一个H5活动,特别是有一定统一结构的活动,都要码一个重复的轮子.后来接到一个基于模板的活动设计系统的需求,便有了下面的内容.借油开车. 组件化 需求一到,接就是怎么实现,技术选型自然 ...

  5. 实现checkbox组件化(Component)

    之前我写了一篇自定义checkbox的文章,通过css3实现自定义的checkbox,并没有使用当今流行的Reactjs, 或者Vuejs之类的进行组件化.但是很显然,这样封装的checkbox组件复 ...

  6. VUE.JS组件化

    VUE.JS组件化 前言 公司目前制作一个H5活动,特别是有一定统一结构的活动,都要码一个重复的轮子.后来接到一个基于模板的活动设计系统的需求,便有了下面的内容.借油开车. 组件化 需求一到,接就是怎 ...

  7. android弹力效果菜单、组件化项目、电影票选座控件的源码

    Android精选源码 android启动扫一扫和收付款的小部件源码 android弹力效果的抽屉菜单源码 对RecyclerView Item做动画 源码 android类似QQ空间,微信朋友圈,微 ...

  8. vue(9)—— 组件化开发 - webpack(3)

    前面两个终于把webpack相关配置解析完了.现在终于进入vue的开发了 vue组件化开发预热 前期准备 创建如下项目: app.js: footer.js: main.js: webpack.con ...

  9. Android组件化demo实现以及遇坑分享

    首先贴出demo的github地址:GitHub - TenzLiu/TenzModuleDemo: android组件化demo 作者:TenzLiu原文链接:https://www.jianshu ...

随机推荐

  1. 个人集群部署hadoop 2.7 + hive 2.1

    环境:centos 6.6 x64 (学习用3节点) 软件:jdk 1.7 + hadoop 2.7.3 + hive 2.1.1 环境准备: 1.安装必要工具 yum -y install open ...

  2. git 配置 SSH密钥

    1.登录用户 $ git config --global user.name "geekfeier" $ git config --global user.email " ...

  3. 表单验证插件-validator.js 使用教程

    做网站的时候,常常会涉及到各种表单验证.选择一款好用的表单验证插件,会降低表单验证开发的难度.在开发中,我目前使用的表单验证插件是:validator.js. validator.js 是一款轻量的表 ...

  4. 【Java基础】JAVA不可变类(immutable)机制与String的不可变性

    一.不可变类简介 不可变类:所谓的不可变类是指这个类的实例一旦创建完成后,就不能改变其成员变量值.如JDK内部自带的很多不可变类:Interger.Long和String(8种基本数据类型的包装类和S ...

  5. Anaconda 安装tensorflow(GPU)

    1.安装 如果是安装CPU模式的tensorflow,只要输入一下代码就可以了 pip3 install tensorflow #python3pip install tensorflow #pyth ...

  6. IIC串行总线的组成及其工作原理

    ------------------最近项目上用到了一款美信的DS1308RTC芯片,由于是挂在了Zynq的PS MIO上,需要软件人员协助才能测试:觉得太麻烦了,想通过飞线,然后在Vivado中调用 ...

  7. TCP/IP详解(整理)

    1.概述 路由器是在网络层进行联通,而网桥是在链路层联通不同的网络. IP层用ICMP来与其他主机或路由器交换错误报文和其他的重要信息.应用程序也可以访问ICMP,两个诊断工具:Ping和Tracer ...

  8. linux系统时钟和硬件时钟不一致

    在做DB2 集群复制的时候要求两台主机时间相互一致. 但是在一台主机上系统时间和硬件时间相差12个小时左右:手动同步后,重启后又相差12个小时左右. 为什么会是这样的,先介绍下系统时钟和硬件时钟的区别 ...

  9. MongoDB官方文档结构

    本文展示MongoDB 3.6.4.0的官方Server文档的结构图——一眼可见完整的知识脉络图.不过,MongoDB除了Server的文档外,还有DRIVERS.CLOUD.TOOLS.DUIDES ...

  10. 简单的TCP接受在转发到客户端的套接口

    //功能:客服端发送tcp包,服务器接受到并打印出来,并将包转换为大写后到客户端//2015.9.10成功 #include <stdio.h>#include <sys/socke ...