基于css动画动态跳动的心
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.box {
width: 200px;
height: 300px;
background-color: #fff;
position: relative;
margin-top: 50px;
margin-left: 50px;
animation: shake 0.5s linear infinite alternate;
}
.lh,
.rh {
width: 100px;
height: 100px;
border-radius: 50%;
background-color: red;
}
.rh {
position: absolute;
right: 30px;
top: 0;
}
.square {
width: 100px;
height: 100px;
background-color: red;
transform: rotate(45deg);
position: absolute;
left: 35px;
top: 34px;
}
@keyframes shake {
from {
transform: scale(.9, .9);
}
to {
transform: scale(1.1, 1.1);
}
}
</style>
</head>
<body>
<div class="box">
<div class="lh"></div>
<div class="rh"></div>
<div class="square"></div>
</div>
</body>
</html>
这是一个纯css的动画,适合刚接触css动画的同学用来练手。