用HTML写一个会动的爱心
时间: 2023-10-26 10:07:35 浏览: 25
以下是一个简单的HTML代码,实现一个会动的爱心:
```
<!DOCTYPE html>
<html>
<head>
<title>动态爱心</title>
<style>
@keyframes beat {
0% {
transform: scale(1);
}
50% {
transform: scale(1.2);
}
100% {
transform: scale(1);
}
}
.heart {
position: absolute;
top: 50%;
left: 50%;
width: 100px;
height: 90px;
transform: translate(-50%, -50%);
background-color: #ff6b6b;
border-radius: 50px 50px 0 0;
transform-origin: center bottom;
animation: beat 1s infinite;
animation-timing-function: linear;
}
.heart:before,
.heart:after {
content: "";
position: absolute;
top: 0;
width: 100px;
height: 100px;
background-color: #ff6b6b;
border-radius: 50px 50px 0 0;
}
.heart:before {
transform: rotate(-45deg);
}
.heart:after {
transform: rotate(45deg);
}
</style>
</head>
<body>
<div class="heart"></div>
</body>
</html>
```
在浏览器中打开这个 HTML 文件,你将会看到一个会动的爱心。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)