帧动画(关键帧@keyframes)
程序员文章站
2024-03-25 12:47:04
...
关键帧
时间进度为30%时,心的形状可以达到最大
<!DOCTYPE>
<head>
<title>帧动画</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<style type="text/css">
body{
padding: 100px;
}
span{
display: inline-block;
}
.heart-left,.heart-right{
width: 50px;
height: 80px;
background-color: red;
border-top-left-radius: 25px;
border-top-right-radius: 25px;
}
.heart-left{
transform: rotateZ(-45deg);
}
.heart-right{
transform: translateX(-28px) rotateZ(45deg);
}
/*动画效果取名beat*/
@keyframes beat{
30%{transform: scale(1.3);}
100%{transform: scale(1);}
}
/*使用动画,加在上面*/
/*beat为动画名称,1.5s为动画时长,infinite动画无限循环*/
.heart{
animation: beat 1.5s infinite;
}
</style>
</head>
<body>
<span class="heart">
<span class="heart-left"></span><span class="heart-right"></span>
</span>
</body>
</html>