<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>心跳动</title>
<style>
div {
width: 800px;
margin: 100px auto;
}
p {
width: 100px;
height: 150px;
background-color: red;
float: left;
border-radius: 50% 50% 0 0;
}
p:nth-child(1) {
transform: rotate(46deg);
transform-origin: right bottom;
/* transform-origin: 100% 100%; 等同于 transform-origin: right bottom;*/
animation: ergou 1s infinite;
}
p:nth-child(2) {
transform: rotate(-46deg);
transform-origin: left bottom;
animation: sangou 1s infinite;
}
@keyframes ergou {
0% {
transform: rotate(46deg) scale(1);
}
50% {
transform: rotate(46deg) scale(1.2);
}
}
@keyframes sangou {
0% {
transform: rotate(-46deg) scale(1);
}
50% {
transform: rotate(-46deg) scale(1.2);
}
}
</style>
</head>
<body>
<div>
<p></p>
<p></p>
</div>
</body>
</html>
上述运行结果: