Web前段基础
HTML02-跳动的心动画效果图
此页面包含的知识点:
-
运动曲线:
linear 匀速
ease-in 慢进快出(由慢到快)
ease-in-out 慢进慢出(由慢到快再有快到慢)
alternate 动画往返 -
动画效果:
animation:scale(动画名称) 1s(执行时长) 0.2s(延迟时间) linear(运动曲线) infinite(运动次数) alternate(往返);
@keyframe 动画名称{
0%{}
100%{}
}
<style>
.square{
width:200px;
height:200px;
background-color:red;
margin:200px auto 0 auto;
position:relative;
/* transform:rotate(45deg);
transform:scale(0.5); */
transform:rotate(45deg) scale(0.5);
animation:scale 1s ease-in infinite alternate;
}
@keyframes scale{
0%{
transform:rotate(45deg) scale(0.5);
}100%{
transform:rotate(45deg) scale(1);
}
}
.circle{
width:200px;
height:200px;
background-color:red;
border-radius:50%;
position:absolute;
}
.circleTop{
top:-100px;
}
.circleLeft{
left:-100px;
}
</style>
</head>
<body>
<div class="square">
<div class="circle circleTop"></div>
<div class="circle circleLeft"></div>
</div>
</body>
</html>