一、無限放大縮小
可以應(yīng)用于跳動的氣球等場景,效果如下:

html部分
<div class="ballon"></div>
css部分
@keyframes scaleDraw { /*定義關(guān)鍵幀、scaleDrew是需要綁定到選擇器的關(guān)鍵幀名稱*/
0%{
transform: scale(1); /*開始為原始大小*/
}
25%{
transform: scale(1.1); /*放大1.1倍*/
}
50%{
transform: scale(1);
}
75%{
transform: scale(1.1);
}
}
.ballon{
width: 150px;
height: 200px;
background: url("images/balloon.png");
background-size: 150px 200px;
-webkit-animation-name: scaleDraw; /*關(guān)鍵幀名稱*/
-webkit-animation-timing-function: ease-in-out; /*動畫的速度曲線*/
-webkit-animation-iteration-count: infinite; /*動畫播放的次數(shù)*/
-webkit-animation-duration: 5s; /*動畫所花費(fèi)的時間*/
/*-webkit-animation: scaleDraw 5s ease-in-out infinite;/*
}
或者是一起控制透明度和大小的變換,如圖

html部分
<button class="button"></button>
css部分
<style type="text/css">
.button{
margin: 100px;
width: 30px;
height:30px;
background: orange;
border-radius: 50px;
animation: flipping 5s infinite;
/*去除button默認(rèn)邊框*/
background-position-x: -7px;
background-position-y: -7px;
border: 1px;
outline: none;
}
@keyframes flipping{
0%{
opacity: .2;
transform: scale(1);
}
25%{
opacity: 1;
box-shadow: 0 0 15px orange;
transform: scale(1.4);
}
50%{
opacity: .2;
transform: scale(1);
}
75%{
opacity: 1;
box-shadow: 0 0 15px orange;
transform: scale(1.4);
}
100%{
opacity: .2;
transform: scale(1);
}
}
</style>
二、漣漪擴(kuò)散

實(shí)質(zhì)就是就是利用了動畫的延遲屬性,兩層圓的動畫相關(guān)的屬性基本相同,除了最外層的圓多設(shè)置了animation-delay屬性
html部分
<div class="live">
<img src="images/live.png" alt="">
<span></span>
<span></span>
</div>
css部分
.live{
position: relative;
width: 100px;
height: 100px;
}
.live img{
width: 100px;
height: 100px;
z-index: 0;
}
@keyframes living {
0%{
transform: scale(1);
opacity: 0.5;
}
50%{
transform: scale(1.5);
opacity: 0; /*圓形放大的同時,透明度逐漸減小為0*/
}
100%{
transform: scale(1);
opacity: 0.5;
}
}
.live span{
position: absolute;
width: 100px;
height: 100px;
left: 0;
bottom: 0;
background: #fff;
border-radius: 50%;
-webkit-animation: living 3s linear infinite;
z-index: -1;
}
.live span:nth-child(2){
-webkit-animation-delay: 1.5s; /*第二個span動畫延遲1.5秒*/
}
三、雷達(dá)

html部分
<div class="container">
<div class="dot"></div>
<div class="pulse p1"></div>
<div class="pulse p2"></div>
</div>
css部分
.container {
position: relative;
}
.dot {
position: absolute;
width: 10px;
height: 10px;
left: 160px;
top: 160px;
border-radius: 50%;
border: 1px solid #33ccff;
background-color: #33ccff;
}
.pulse {
position: absolute;
width: 88px;
height: 88px;
left: 120px;
top: 120px;
border: 2px solid #3399ff;
border-radius: 50%;
opacity: 0;
}
.p1 {
animation: warn 2s ease-out infinite;
}
.p2 {
animation: warn2 2s ease-out infinite;
}
/*.p1 {
animation: warn 2s ease-out infinite;
}
.p2 {
animation: warn 2s ease-out infinite;
-webkit-animation-delay: 1.5s;
}*/
@keyframes warn {
0% {transform: scale(0.3);opacity: 0.0;}
25% {transform: scale(0.3);opacity: 0.1;}
50% {transform: scale(0.5);opacity: 0.3;}
75% {transform: scale(0.8);opacity: 0.5;}
100% {transform: scale(1);opacity: 0.0;}
}
@keyframes warn2 {
0% {transform: scale(0.3);opacity: 0.0;}
25% {transform: scale(0.3);opacity: 0.1;}
50% {transform: scale(0.3);opacity: 0.3;}
75% {transform: scale(0.5);opacity: 0.5;}
100% {transform: scale(0.8);opacity: 0.0;}
}
四、加載loading


loading.png
實(shí)質(zhì)就是讓包裹loading.png圖片的元素360度循環(huán)的轉(zhuǎn)動。
html部分
<div class="loading">
<img src="./loading.png">
</div>
css部分
.loading{
width: 80px;
height: 80px;
animation: spin 1.2s linear infinite;
}
.loading img{
width:100%;
height:100%;
}
@keyframes spin
{
0% {transform: rotate(0deg);}
100% {transform: rotate(360deg);}
}
也可用字體圖標(biāo)來代替圖片。
更多l(xiāng)oading小動畫參見純CSS3加載Loading動畫圖 12款創(chuàng)意設(shè)計(jì)

5f8cw-u3geg.gif