爱心html网页代码
时间: 2023-11-20 22:56:23 浏览: 191
基于HTML实现的爱心代码-添加了文字.zip
以下是一个简单的爱心HTML网页代码,其中包含了CSS样式和JavaScript代码,可以实现爱心的动态效果:
```html
<!DOCTYPE html>
<html>
<head>
<title>爱心网页</title>
<style>
body {
background-color: #f8f8f8;
}
.heart {
position: absolute;
width: 100px;
height: 90px;
transform: rotate(-45deg);
background-color: #ff6b6b;
animation: pulse 1s ease-in-out infinite;
}
.heart:before,
.heart:after {
position: absolute;
content: "";
width: 100px;
height: 90px;
background-color: #ff6b6b;
border-radius: 50px 50px 0 0;
}
.heart:before {
top: -45px;
left: 0;
}
.heart:after {
top: 0;
left: 45px;
}
@keyframes pulse {
0% {
transform: scale(0.8);
}
50% {
transform: scale(1);
}
100% {
transform: scale(0.8);
}
}
</style>
</head>
<body>
<div class="heart"></div>
<script>
document.addEventListener("mousemove", function(event) {
var heart = document.querySelector(".heart");
var x = event.clientX - heart.offsetWidth / 2;
var y = event.clientY - heart.offsetHeight / 2;
heart.style.left = x + "px";
heart.style.top = y + "px";
});
</script>
</body>
</html>
```
阅读全文