css制作灯笼
使用CSS制作灯笼
通过CSS的盒模型、阴影和动画效果可以创建一个动态的灯笼效果。以下是一个完整的实现方法:
HTML结构
<div class="lantern">
<div class="lantern-body"></div>
<div class="lantern-top"></div>
<div class="lantern-bottom"></div>
<div class="lantern-light"></div>
</div>
CSS样式
.lantern {
position: relative;
width: 120px;
height: 180px;
margin: 50px auto;
}
.lantern-body {
width: 100%;
height: 150px;
background-color: #ff4d4d;
border-radius: 50% 50% 10% 10%;
box-shadow:
0 0 20px #ff9999,
0 0 40px #ff6666,
0 0 60px #ff3333;
position: relative;
z-index: 1;
}
.lantern-top, .lantern-bottom {
position: absolute;
width: 140px;
height: 20px;
background-color: #e6b800;
border-radius: 5px;
left: -10px;
z-index: 2;
}
.lantern-top {
top: -10px;
}
.lantern-bottom {
bottom: 0;
}
.lantern-light {
position: absolute;
width: 60px;
height: 80px;
background-color: #ffff99;
border-radius: 50%;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
filter: blur(10px);
animation: flicker 2s infinite alternate;
}
@keyframes flicker {
0% { opacity: 0.8; }
50% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
100% { opacity: 0.7; }
}
灯笼设计要点
形状设计
- 主体使用圆形底部渐收的形状
- 顶部和底部添加金属装饰条
- 内部光晕使用模糊效果
颜色选择
- 灯笼主体使用传统红色 (#ff4d4d)
- 金属装饰使用金色 (#e6b800)
- 内部光源使用暖黄色 (#ffff99)
动画效果
- 添加呼吸灯效果的闪烁动画
- 使用transform实现光源脉动
- 透明度变化模拟烛光摇曳
增强效果的方法
添加灯笼穗装饰:
.lantern::after {
content: "";
position: absolute;
bottom: -40px;
left: 50%;
transform: translateX(-50%);
width: 4px;
height: 30px;
background: linear-gradient(to bottom, #e6b800, #996600);
}
添加文字装饰:

.lantern-body::before {
content: "福";
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 40px;
color: #ffcc00;
text-shadow: 1px 1px 2px #000;
}
这个实现使用了纯CSS技术,不需要JavaScript即可获得完整的动画效果。通过调整尺寸、颜色和动画参数,可以创建不同风格的灯笼效果。






