<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS3鼠标经过开花动画特效</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #222;
font-family: 'Arial', sans-serif;
overflow: hidden;
}
.flower-container {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 30px;
padding: 30px;
max-width: 1000px;
}
.flower {
position: relative;
width: 120px;
height: 120px;
cursor: pointer;
transition: transform 0.3s;
}
.flower:hover {
transform: scale(1.1);
}
.flower-center {
position: absolute;
width: 30px;
height: 30px;
background: #ffd700;
border-radius: 50%;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 10;
box-shadow: 0 0 10px rgba(255, 215, 0, 0.7);
}
.petal {
position: absolute;
width: 20px;
height: 50px;
background: #ff69b4;
border-radius: 50% 50% 0 0;
top: 50%;
left: 50%;
transform-origin: bottom center;
opacity: 0;
transition: all 0.5s ease;
box-shadow: 0 0 10px rgba(255, 105, 180, 0.5);
}
.flower:hover .petal {
opacity: 1;
}
/* 创建花瓣旋转效果 */
.flower:hover .petal:nth-child(1) {
transform: translate(-50%, -50%) rotate(0deg) translateY(-40px);
}
.flower:hover .petal:nth-child(2) {
transform: translate(-50%, -50%) rotate(45deg) translateY(-40px);
}
.flower:hover .petal:nth-child(3) {
transform: translate(-50%, -50%) rotate(90deg) translateY(-40px);
}
.flower:hover .petal:nth-child(4) {
transform: translate(-50%, -50%) rotate(135deg) translateY(-40px);
}
.flower:hover .petal:nth-child(5) {
transform: translate(-50%, -50%) rotate(180deg) translateY(-40px);
}
.flower:hover .petal:nth-child(6) {
transform: translate(-50%, -50%) rotate(225deg) translateY(-40px);
}
.flower:hover .petal:nth-child(7) {
transform: translate(-50%, -50%) rotate(270deg) translateY(-40px);
}
.flower:hover .petal:nth-child(8) {
transform: translate(-50%, -50%) rotate(315deg) translateY(-40px);
}
/* 添加一些变化的花瓣 */
.flower:nth-child(2) .petal {
background: #9370db;
box-shadow: 0 0 10px rgba(147, 112, 219, 0.5);
}
.flower:nth-child(2) .flower-center {
background: #ff6347;
box-shadow: 0 0 10px rgba(255, 99, 71, 0.7);
}
.flower:nth-child(3) .petal {
background: #00fa9a;
box-shadow: 0 0 10px rgba(0, 250, 154, 0.5);
}
.flower:nth-child(3) .flower-center {
background: #ff00ff;
box-shadow: 0 0 10px rgba(255, 0, 255, 0.7);
}
.title {
position: fixed;
top: 20px;
color: #fff;
font-size: 28px;
font-weight: bold;
text-align: center;
text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}
.credit {
position: fixed;
bottom: 20px;
color: rgba(255, 255, 255, 0.7);
font-size: 14px;
}
.credit a {
color: #ff69b4;
text-decoration: none;
}
</style>
</head>
<body>
<div class="title">CSS3鼠标经过开花动画</div>
<div class="flower-container">
<div class="flower">
<div class="flower-center"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
</div>
<div class="flower">
<div class="flower-center"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
</div>
<div class="flower">
<div class="flower-center"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
</div>
</div>
</body>
</html>
CSS3鼠标经过开花动画特效
于 2025-06-23 14:21:10 首次发布