css发光按钮制作
CSS发光按钮制作方法
使用CSS可以轻松创建发光按钮效果,主要通过box-shadow、transition和伪元素实现。以下是几种常见方法:
基础发光效果
.glow-button {
background-color: #4CAF50;
border: none;
color: white;
padding: 12px 24px;
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;
}
渐变发光效果
.gradient-glow {
background: linear-gradient(to right, #ff8a00, #da1b60);
color: white;
padding: 12px 24px;
border: none;
border-radius: 30px;
box-shadow: 0 4px 15px rgba(218, 27, 96, 0.4);
transition: all 0.3s ease;
}
.gradient-glow:hover {
box-shadow: 0 6px 20px rgba(218, 27, 96, 0.6);
transform: translateY(-2px);
}
霓虹灯效果
.neon-button {
background-color: transparent;
color: #fff;
border: 2px solid #0fa;
padding: 12px 24px;
font-size: 16px;
text-transform: uppercase;
letter-spacing: 2px;
border-radius: 0;
box-shadow: 0 0 10px #0fa, 0 0 20px #0fa;
transition: all 0.3s ease;
position: relative;
overflow: hidden;
}
.neon-button:hover {
box-shadow: 0 0 20px #0fa, 0 0 40px #0fa;
background-color: #0fa;
color: #000;
}
脉冲发光效果

.pulse-button {
background-color: #ff4757;
color: white;
border: none;
padding: 12px 24px;
border-radius: 50px;
position: relative;
animation: pulse 2s infinite;
}
@keyframes pulse {
0% {
box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.7);
}
70% {
box-shadow: 0 0 0 10px rgba(255, 71, 87, 0);
}
100% {
box-shadow: 0 0 0 0 rgba(255, 71, 87, 0);
}
}
实现要点
box-shadow属性控制发光效果,四个值分别表示:水平偏移、垂直偏移、模糊半径和颜色transition属性添加平滑的动画过渡效果- 使用
:hover伪类实现鼠标悬停时的效果变化 - 渐变背景可以结合发光效果创造更丰富的视觉体验
- 动画效果可以通过
@keyframes实现周期性发光
这些效果可以根据需要调整颜色、大小和动画参数来适应不同的设计需求。






