基本使用方法:
先在style定义动画的名字及序列
@keyframes move {
0%{
transform: translate(0 0);
}
25%{
transform: translate(1000px,0);
}
50%{
transform: translate(1000px,200px);
}
75%{
transform: translate(0,200px);
}
100%{
transform: translate(0,0);
}
}
再在css中调用,一般来说最少需要两个语句:
一个是对应的动画名字,一个是持续时间:
div{
height: 100px;
width: 100px;
background-color: pink;
animation-name: move;
animation-duration: 3s;
}
常见属性:
简写:
案例,波纹效果:
<style>
.city{
position: relative;
width: 200px;
height: 200px;
margin: 100px auto;
}
.dotted{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
width: 20px;
height: 20px;
border-radius: 50%;
background-color: blue;
}
.city div[class^="pulse"]{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
width: 20px;
height: 20px;
box-shadow: 0 0 12px blue;
border-radius: 50%;
animation: move 1.2s linear infinite;
}
@keyframes move {
0%{}
70%{
width: 60px;
height: 60px;
opacity: 1;
}
100%{
width: 90px;
height: 90px;
opacity: 0;
}
}
.city .pulse2 {
animation-delay: 0.4s!important;
}
.city .pulse3{
animation-delay: 0.8s!important;
}
</style>
</head>
<body>
<div class="city">
<div class="dotted"></div>
<div class="pulse1"></div>
<div class="pulse2"></div>
<div class="pulse3"></div>
</div>
</body>
animation-timing-function:取值:
steps()指的是几步完成动画 ,写了就不用写linear或者ease了