HTML5七夕情人节表白特效代码
时间: 2023-08-01 16:13:04 浏览: 131
以下是HTML5七夕表白特效代码示例:
```
<!DOCTYPE html>
<html>
<head>
<title>七夕表白特效</title>
<meta charset="utf-8">
<style>
body {
background-color: #FDF5E6;
}
h1 {
font-size: 3em;
font-family: Arial, sans-serif;
text-align: center;
color: #FF69B4;
margin-top: 50px;
}
.container {
display: flex;
justify-content: center;
align-items: center;
margin-top: 50px;
}
.heart {
position: relative;
width: 100px;
height: 90px;
transform: rotate(45deg);
cursor: pointer;
animation: beat 1s ease infinite;
}
.heart:before,
.heart:after {
content: "";
position: absolute;
left: 50px;
top: 0;
width: 50px;
height: 80px;
background-color: #FF69B4;
border-radius: 50px 50px 0 0;
}
.heart:before {
transform: rotate(-45deg);
}
.heart:after {
left: 0;
transform: rotate(45deg);
}
.heart:hover {
animation-play-state: paused;
}
@keyframes beat {
0% { transform: scale(1); }
50% { transform: scale(1.2); }
100% { transform: scale(1); }
}
</style>
</head>
<body>
<h1>七夕表白,心动不如行动!</h1>
<div class="container">
<div class="heart"></div>
</div>
<script>
const heart = document.querySelector('.heart');
heart.addEventListener('click', function () {
alert('我喜欢你!');
});
</script>
</body>
</html>
```
这是一个基于CSS3动画和JavaScript交互实现的七夕表白特效,使用了心形图案和动态闪烁的动画效果,点击心形图案会弹出窗口提示“我喜欢你!”
阅读全文