简单css特效制作
悬停放大效果
通过transform: scale()实现元素悬停时放大,搭配transition平滑过渡:
.box {
width: 200px;
height: 200px;
transition: transform 0.3s ease;
}
.box:hover {
transform: scale(1.1);
}
渐变背景动画
使用linear-gradient和animation创建流动渐变背景:

.element {
background: linear-gradient(90deg, #ff9a9e, #fad0c4);
background-size: 400% 400%;
animation: gradientBG 5s ease infinite;
}
@keyframes gradientBG {
0% { background-position: 0% 50% }
50% { background-position: 100% 50% }
100% { background-position: 0% 50% }
}
文字阴影效果
通过多层text-shadow创造立体文字:
.text-3d {
color: white;
text-shadow:
0 1px 0 #ccc,
0 2px 0 #bbb,
0 3px 0 #aaa,
0 4px 5px rgba(0,0,0,0.2);
}
按钮点击波纹
利用伪元素和动画实现Material Design风格的点击波纹:

.btn {
position: relative;
overflow: hidden;
}
.btn:after {
content: "";
position: absolute;
top: 50%;
left: 50%;
width: 5px;
height: 5px;
background: rgba(255,255,255,0.5);
opacity: 0;
border-radius: 100%;
transform: scale(1,1) translate(-50%);
transform-origin: 50% 50%;
}
.btn:active:after {
animation: ripple 0.6s ease-out;
}
@keyframes ripple {
0% { transform: scale(0,0); opacity: 1; }
100% { transform: scale(20,20); opacity: 0; }
}
卡片翻转效果
通过transform-style: preserve-3d实现3D翻转:
.card {
position: relative;
transform-style: preserve-3d;
transition: all 0.8s ease;
}
.card:hover {
transform: rotateY(180deg);
}
.front, .back {
position: absolute;
backface-visibility: hidden;
}
.back {
transform: rotateY(180deg);
}
霓虹文字边框
结合box-shadow和text-shadow创建发光效果:
.neon {
color: #fff;
text-shadow:
0 0 5px #fff,
0 0 10px #fff,
0 0 20px #ff00de;
box-shadow:
0 0 5px #fff,
inset 0 0 5px #fff,
0 0 20px #08f,
inset 0 0 20px #08f;
}






