html新年快乐代码带动图
时间: 2024-12-31 14:22:27 浏览: 10
### 带有动画效果的新年贺卡 HTML 代码示例
为了创建一个具有动画效果的新年贺卡,可以利用HTML和CSS来实现。下面是一个简单的例子:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>新年快乐</title>
<style>
body {
background-color: #ffeb3b;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.card {
width: 300px;
padding: 20px;
text-align: center;
box-shadow: 0 4px 8px rgba(0,0,0,.2);
border-radius: 15px;
position: relative;
overflow: hidden;
animation-name: fadeInDown;
animation-duration: 2s;
background-image: url('https://example.com/new_year_image.jpg'); /* 替换成实际图片链接 */
color: white;
font-family: Arial, sans-serif;
}
@keyframes fadeInDown {
from { opacity: 0; transform: translate3d(0,-100%,0); }
to { opacity: 1; transform: none; }
}
h1 {
font-size: 2em;
margin-bottom: 0.5em;
}
p {
line-height: 1.5;
}
span.greeting {
font-weight: bold;
color: red;
}
div.confetti {
position: absolute;
top: -20%;
left: -20%;
width: 150px;
height: 150px;
background-color: yellow;
clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
animation-name: fallAndRotate;
animation-duration: 5s;
animation-timing-function: linear;
animation-iteration-count: infinite;
}
@keyframes fallAndRotate {
0% {transform: translateY(-10%) rotate(0deg);}
100% {transform: translateY(110%) rotate(360deg);}
}
</style>
</head>
<body>
<div class="card">
<h1>新年快乐!</h1>
<p><span class="greeting">亲爱的用户,</span></p>
<p>愿新的一年带来更多的幸福与成功。</p>
<!-- 添加一些彩带作为装饰 -->
<div class="confetti"></div>
<div class="confetti" style="left: auto; right: -20%;"></div>
</div>
</body>
</html>
```
此段代码定义了一个带有渐入下降动画的卡片容器以及两个不断旋转下落的小图标模拟飘动的彩带效果[^1]。
阅读全文