css 发光按钮制作
制作CSS发光按钮的方法
使用CSS的box-shadow和text-shadow属性可以轻松创建发光效果按钮。以下是几种实现方式:
基础发光效果
.glow-button {
background-color: #4CAF50;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
border-radius: 8px;
box-shadow: 0 0 10px #4CAF50;
transition: box-shadow 0.3s ease;
}
.glow-button:hover {
box-shadow: 0 0 20px #4CAF50;
}
多彩渐变发光
.rainbow-glow {
background: linear-gradient(90deg, #ff0000, #ff7300, #fffb00, #48ff00, #00ffd5, #002bff, #7a00ff, #ff00c8, #ff0000);
background-size: 400%;
border-radius: 50px;
color: white;
padding: 15px 30px;
position: relative;
z-index: 1;
}
.rainbow-glow::before {
content: '';
position: absolute;
top: -5px;
left: -5px;
right: -5px;
bottom: -5px;
z-index: -1;
background: inherit;
background-size: 400%;
border-radius: 50px;
opacity: 0;
transition: 0.5s;
filter: blur(20px);
}
.rainbow-glow:hover::before {
opacity: 1;
animation: glow 8s linear infinite;
}
@keyframes glow {
0% { background-position: 0 0; }
50% { background-position: 400% 0; }
100% { background-position: 0 0; }
}
霓虹灯效果
.neon-button {
color: #fff;
text-transform: uppercase;
background: transparent;
padding: 20px;
border: 4px solid #fff;
border-radius: 10px;
position: relative;
transition: 0.5s;
}
.neon-button:hover {
color: #fff;
background: #ff00ff;
box-shadow: 0 0 10px #ff00ff,
0 0 30px #ff00ff,
0 0 60px #ff00ff;
text-shadow: 0 0 5px #fff,
0 0 10px #fff;
}
悬停脉冲效果
.pulse-button {
background: #5e5eff;
color: white;
border: none;
padding: 15px 40px;
font-size: 18px;
border-radius: 50px;
position: relative;
animation: pulse 2s infinite;
}
@keyframes pulse {
0% { box-shadow: 0 0 0 0 rgba(94, 94, 255, 0.7); }
70% { box-shadow: 0 0 0 20px rgba(94, 94, 255, 0); }
100% { box-shadow: 0 0 0 0 rgba(94, 94, 255, 0); }
}
这些示例展示了不同风格的发光按钮效果,可以根据需要调整颜色、大小和动画参数来创建独特的发光按钮。







