css 发光按钮制作
基础发光按钮制作
创建一个基础的CSS发光按钮,可以使用box-shadow属性来实现发光效果。以下是一个简单的示例代码:
.glow-button {
padding: 10px 20px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
transition: all 0.3s ease;
box-shadow: 0 0 10px #4CAF50;
}
.glow-button:hover {
box-shadow: 0 0 20px #4CAF50;
}
渐变发光效果
通过结合CSS渐变和阴影效果,可以创建更复杂的发光按钮:
.gradient-glow-button {
padding: 12px 24px;
background: linear-gradient(45deg, #ff00cc, #3333ff);
color: white;
border: none;
border-radius: 8px;
font-size: 18px;
cursor: pointer;
transition: all 0.3s ease;
box-shadow: 0 0 15px rgba(255, 0, 204, 0.5);
}
.gradient-glow-button:hover {
box-shadow: 0 0 25px rgba(51, 51, 255, 0.7);
}
脉冲发光动画
使用CSS动画可以创建脉冲发光效果,让按钮更具吸引力:
.pulse-button {
padding: 12px 24px;
background-color: #ff5722;
color: white;
border: none;
border-radius: 6px;
font-size: 16px;
cursor: pointer;
animation: pulse 2s infinite;
}
@keyframes pulse {
0% {
box-shadow: 0 0 0 0 rgba(255, 87, 34, 0.7);
}
70% {
box-shadow: 0 0 0 15px rgba(255, 87, 34, 0);
}
100% {
box-shadow: 0 0 0 0 rgba(255, 87, 34, 0);
}
}
外边框发光效果
通过伪元素和边框属性可以创建外边框发光效果:
.border-glow-button {
position: relative;
padding: 12px 24px;
background-color: transparent;
color: white;
border: 2px solid #00bcd4;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
transition: all 0.3s ease;
}
.border-glow-button::before {
content: '';
position: absolute;
top: -5px;
left: -5px;
right: -5px;
bottom: -5px;
border: 2px solid #00bcd4;
border-radius: 8px;
opacity: 0;
transition: all 0.3s ease;
}
.border-glow-button:hover::before {
opacity: 1;
box-shadow: 0 0 15px #00bcd4;
}
文字发光效果
为按钮文字添加发光效果可以增强视觉冲击力:
.text-glow-button {
padding: 12px 24px;
background-color: #3f51b5;
color: white;
border: none;
border-radius: 5px;
font-size: 18px;
cursor: pointer;
transition: all 0.3s ease;
text-shadow: 0 0 5px white;
}
.text-glow-button:hover {
text-shadow: 0 0 10px white, 0 0 20px white;
}
霓虹灯效果按钮
模拟霓虹灯效果的按钮可以使用以下CSS代码:
.neon-button {
padding: 15px 30px;
background-color: transparent;
color: #ff00ff;
border: 4px solid #ff00ff;
border-radius: 10px;
font-size: 20px;
font-weight: bold;
cursor: pointer;
transition: all 0.3s ease;
box-shadow: 0 0 10px #ff00ff, inset 0 0 10px #ff00ff;
text-shadow: 0 0 5px #ff00ff;
}
.neon-button:hover {
box-shadow: 0 0 20px #ff00ff, inset 0 0 20px #ff00ff;
text-shadow: 0 0 10px #ff00ff;
}
这些方法可以根据需要组合使用,调整颜色、大小和动画参数来创建各种不同的发光按钮效果。







