效果预览:手机端点击 电脑端点击
代码:
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>跳动的心</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.heart {
margin: 54% 35%;
position: relative;
display: inline-block;
max-width: 100%;
animation: heart 800ms infinite alternate;
}
@keyframes heart {
0% {
transform: scale(1);
}
100% {
transform: scale(1.5);
}
}
.heart:hover {
transform: scale(1.5);
}
.heart > .left {
width: 120px;
height: 120px;
position: absolute;
transform: rotate(45deg) translateX(100px);
border-radius: 50% 0 0 50%;
bottom: 100%;
right: 100%;
background: red;
}
.heart > .right {
width: 120px;
height: 120px;
position: absolute;
transform: rotate(45deg) translateY(100px);
border-radius: 50% 50% 0 0;
bottom: 100%;
background: red;
left: 100%;
}
.heart > .an {
width: 120px;
height: 120px;
background: red;
transform: rotate(45deg);
}
</style>
</head>
<body>
<div class="heart">
<div class="left"></div>
<div class="right"></div>
<div class="an"></div>
</div>
</body>
</html>