CSS模板制作起泡
起泡效果制作方法
使用CSS的box-shadow属性可以创建起泡效果。通过多层阴影叠加,模拟气泡的光影变化。
.bubble {
width: 100px;
height: 100px;
background: rgba(255,255,255,0.7);
border-radius: 50%;
box-shadow:
0 0 10px rgba(255,255,255,0.8),
inset 0 0 20px rgba(255,255,255,1),
inset 10px 0 20px rgba(255,192,203,0.8);
}
动态起泡效果
结合CSS动画让气泡产生浮动效果,增强真实感。
@keyframes float {
0% { transform: translateY(0) rotate(0deg); }
50% { transform: translateY(-20px) rotate(5deg); }
100% { transform: translateY(0) rotate(0deg); }
}
.bubble {
animation: float 3s ease-in-out infinite;
}
复杂气泡样式
通过伪元素添加更多细节,创造更真实的起泡效果。
.bubble::before {
content: '';
position: absolute;
top: 15px;
left: 20px;
width: 20px;
height: 20px;
background: rgba(255,255,255,0.9);
border-radius: 50%;
filter: blur(2px);
}
响应式气泡
使用视窗单位确保气泡在不同设备上保持比例。
.bubble {
width: 10vw;
height: 10vw;
min-width: 50px;
min-height: 50px;
}





