用HTML+CSS+JS做一个闪动的心网页
时间: 2023-12-17 07:04:54 浏览: 37
好的,下面是一个简单的闪动心的网页实现,你可以将其保存为 HTML 文件并在浏览器中打开。
```html
<!DOCTYPE html>
<html>
<head>
<title>闪动的心</title>
<style>
body {
background-color: #f5f5f5;
}
.heart {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 50px;
height: 50px;
background-color: #ff69b4;
animation: heartbeat 1s ease-in-out infinite;
border-radius: 50% 50% 0 0;
transform-origin: center bottom;
}
.heart::before, .heart::after {
content: "";
position: absolute;
left: 0;
top: -50%;
width: 50px;
height: 50px;
background-color: #ff69b4;
border-radius: 50% 50% 0 0;
}
.heart::before {
transform: rotate(-45deg);
}
.heart::after {
transform: rotate(45deg);
}
@keyframes heartbeat {
0% {
transform: scale(1);
}
50% {
transform: scale(1.2);
}
100% {
transform: scale(1);
}
}
</style>
</head>
<body>
<div class="heart"></div>
</body>
</html>
```
这个页面通过 CSS 的动画实现了一个闪动的心,并且使用了绝对定位将其居中显示在页面中央。你可以根据需要自行调整样式和动画的参数。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.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)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)