CSS3组件化之圆波扩散
本篇文章主要介绍用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组件化之圆波扩散的更多相关文章
- CSS3组件化之ios版菊花loading
<div class="juhua-loading"> <div class="jh-circle1 jh-circle-ios">&l ...
- CSS3组件化之菊花loading
<div class="juhua-loading"> <div class="jh-circle"></div> < ...
- CSS3组件化之单线箭头
<div class="parent-box"> <div class="top-arrow"></div> <div ...
- vue.js组件化开发实践
前言 公司目前制作一个H5活动,特别是有一定统一结构的活动,都要码一个重复的轮子.后来接到一个基于模板的活动设计系统的需求,便有了下面的内容.借油开车. 组件化 需求一到,接就是怎么实现,技术选型自然 ...
- 实现checkbox组件化(Component)
之前我写了一篇自定义checkbox的文章,通过css3实现自定义的checkbox,并没有使用当今流行的Reactjs, 或者Vuejs之类的进行组件化.但是很显然,这样封装的checkbox组件复 ...
- VUE.JS组件化
VUE.JS组件化 前言 公司目前制作一个H5活动,特别是有一定统一结构的活动,都要码一个重复的轮子.后来接到一个基于模板的活动设计系统的需求,便有了下面的内容.借油开车. 组件化 需求一到,接就是怎 ...
- android弹力效果菜单、组件化项目、电影票选座控件的源码
Android精选源码 android启动扫一扫和收付款的小部件源码 android弹力效果的抽屉菜单源码 对RecyclerView Item做动画 源码 android类似QQ空间,微信朋友圈,微 ...
- vue(9)—— 组件化开发 - webpack(3)
前面两个终于把webpack相关配置解析完了.现在终于进入vue的开发了 vue组件化开发预热 前期准备 创建如下项目: app.js: footer.js: main.js: webpack.con ...
- Android组件化demo实现以及遇坑分享
首先贴出demo的github地址:GitHub - TenzLiu/TenzModuleDemo: android组件化demo 作者:TenzLiu原文链接:https://www.jianshu ...
随机推荐
- 20155305乔磊2016-2017-2《Java程序设计》第八周学习总结
20155305乔磊2016-2017-2<Java程序设计>第八周学习总结 教材学习内容总结 通用API 日志API 1.java.util.logging包提供了日志功能相关类与接口, ...
- 去除zabbix calculate 模式下,有时候分母为零的情况(Cannot evaluate expression: division by zero. )
zabbix的监控类型支持一种calculate的方式,可以对几个item结果进行简单的计算,但有时会出现分母为零的情况,这时候监控项就会报错 Cannot evaluate expression: ...
- CSS基础之选择器
一:CSS介绍 CSS(Cascading Style Sheet,层叠样式表)定义如何显示HTML元素. 当浏览器读到,一个样式表时,就会按照. 二:CSS语法 每个CSS有两部分组成:选择器和声明 ...
- JavaScript 优雅的实现方式包含你可能不知道的知识点
有些东西很好用,但是你未必知道:有些东西你可能用过,但是你未必知道原理. 实现一个目的有多种途径,俗话说,条条大路通罗马.很多内容来自平时的一些收集以及过往博客文章底下的精彩评论,收集整理拓展一波,发 ...
- aarch64_n1
NFStest-2.1.5-0.fc26.noarch.rpm 2017-02-17 01:19 531K fedora Mirroring Project NLopt-2.4.2-11.fc26.a ...
- 企业日志大数据分析系统ELK+KAFKA实现【转】
背景: 最近线上上了ELK,但是只用了一台Redis在中间作为消息队列,以减轻前端es集群的压力,Redis的集群解决方案暂时没有接触过,并且Redis作为消息队列并不是它的强项:所以最近将Redis ...
- 分享一个自己写的vue多语言插件smart-vue-i18n
前言 目前有比较成熟的方案(vue-i18n)了解了下,并且实用了一下感觉对于我在使用的项目来说略显臃肿,功能比较多,所以压缩的会比较大,在移动端不太适合所以自己花一天时间撸了一个vue多语言插件,压 ...
- Laravel 程序架构设计思路:使用动作类
当我们谈论到应用程序的架构的时候,经常会问到一个经典的问题,那就是"这段代码应该放在哪里比较好". 因为 Laravel 是一个相当灵活的框架,所以要回答这个问题其实没那么容易.我 ...
- 2018JAVA复习摘要
由于公司内部原因,2018年感觉自己可能会换个新环境:虽然时间尚未确定,但还是得提前做好防范,毕竟面试复习是需要时间好好准备才能拿到自己理想的offer.打算从清明节之后开始好复习基本知识要点,先整理 ...
- 数据库中INFORMATION_SCHEMA的说明及使用
第一个查询看看库里有多少个表,表名等select * from INFORMATION_SCHEMA.TABLES information_schema这张数据表保存了MySQL服务器所有数据库的信息 ...