写一段html代码,要求展示跳动的爱心
时间: 2023-10-26 12:02:27 浏览: 43
可以使用CSS3的动画来实现这个效果,以下是一个示例代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>跳动的爱心</title>
<style type="text/css">
@keyframes heartbeat {
0% {
transform: scale(1);
}
25% {
transform: scale(1.2);
}
50% {
transform: scale(1);
}
75% {
transform: scale(1.2);
}
100% {
transform: scale(1);
}
}
.heart {
position: relative;
display: inline-block;
width: 50px;
height: 50px;
transform: rotate(45deg);
animation: heartbeat 1s ease-in-out infinite;
}
.heart:before,
.heart:after {
position: absolute;
content: "";
left: 20px;
top: 0;
width: 30px;
height: 45px;
background-color: red;
border-radius: 30px 30px 0 0;
}
.heart:after {
left: 0;
border-radius: 0 0 30px 30px;
}
</style>
</head>
<body>
<div class="heart"></div>
</body>
</html>
```
这段代码会在页面中展示一个跳动的红色爱心。可以根据需要调整爱心的大小、颜色等。