发光按钮(HTML & CSS):
HTML:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Glowing buttons</title>
</head>
<body>
<!-- Blue -->
<a href="#" class="button blue">Hello World</a>
<!-- Yellow -->
<a href="#" class="button yellow">Hello World</a>
<!-- White -->
<a href="#" class="button white">Hello World</a>
</body>
</html>
指南针 (SCSS):
@import "compass/css3/images";
@import "compass/css3/border-radius";
@import "compass/css3/box-shadow";
@import "compass/css3/animation";
body {
background: #000 url('http://subtlepatterns.com/patterns/office.png');
padding: 30px;
font-family: "Helvetica Neue", "Helvetica", sans-serif;
}
/* Blue Shadow */
@include keyframes(blue) {
0%, 100%{
@include box-shadow(1px 0px 19px 4px rgba(0, 130, 196, 0.7), inset 0px 0px 10px rgba(255, 255, 255, 0.5));
}
50% {
@include box-shadow(0px 0px 0px 0px rgba(0, 130, 196, 0), inset 0px 0px 0px rgba(255, 255, 255, 0));
}
}
/* Yellow Shadow */
@include keyframes(yellow) {
0%, 100%{
@include box-shadow(1px 0px 19px 4px rgba(255, 245, 3, 1), inset 0px 0px 10px rgba(255, 255, 255, 0.5));
}
50% {
@include box-shadow(0px 0px 0px 0px rgba(255, 245, 3, 0), inset 0px 0px 0px rgba(255, 255, 255, 0));
}
}
/* White Shadow */
@include keyframes(white) {
0%, 100%{
@include box-shadow(1px 0px 19px 4px rgba(255, 255, 255, 0.7), inset 0px 0px 10px rgba(255, 255, 255, 0.5));
}
50% {
@include box-shadow(0px 0px 0px 0px rgba(255, 255, 255, 0), inset 0px 0px 0px rgba(255, 255, 255, 0));
}
}
/* Button */
.button {
text-align: center;
padding: 10px 20px;
text-decoration: none;
color: #000;
font-weight: bold;
@include border-radius(10px 0);
margin-right: 20px;
}
/* Blue Background */
.blue {
text-shadow: 0px 1px 0px #83e0f7;
@include background-image(linear-gradient(top, #87e0fd, #53cbf1));
@include animation(blue 2s infinite);
}
/* Yellow Background */
.yellow {
text-shadow: 0px 1px 0px #faffc7;
@include background-image(linear-gradient(top, #fff966, #f3fd80));
@include animation(yellow 2s infinite);
}
/* White Background */
.white {
text-shadow: 0px 1px 0px #fff;
@include background-image(linear-gradient(top, #fff, #ccc));
@include animation(white 2s infinite);
}
CSS:
body {
background: black url("http://subtlepatterns.com/patterns/office.png");
padding: 30px;
font-family: "Helvetica Neue", "Helvetica", sans-serif; }
/* Blue Shadow */
@-moz-keyframes blue {
0%, 100% {
-moz-box-shadow: 1px 0px 19px 4px rgba(0, 130, 196, 0.7), inset 0px 0px 10px rgba(255, 255, 255, 0.5);
box-shadow: 1px 0px 19px 4px rgba(0, 130, 196, 0.7), inset 0px 0px 10px rgba(255, 255, 255, 0.5); }
50% {
-moz-box-shadow: 0px 0px 0px 0px rgba(0, 130, 196, 0), inset 0px 0px 0px rgba(255, 255, 255, 0);
box-shadow: 0px 0px 0px 0px rgba(0, 130, 196, 0), inset 0px 0px 0px rgba(255, 255, 255, 0); } }
@-webkit-keyframes blue {
0%, 100% {
-webkit-box-shadow: 1px 0px 19px 4px rgba(0, 130, 196, 0.7), inset 0px 0px 10px rgba(255, 255, 255, 0.5);
box-shadow: 1px 0px 19px 4px rgba(0, 130, 196, 0.7), inset 0px 0px 10px rgba(255, 255, 255, 0.5); }
50% {
-webkit-box-shadow: 0px 0px 0px 0px rgba(0, 130, 196, 0), inset 0px 0px 0px rgba(255, 255, 255, 0);
box-shadow: 0px 0px 0px 0px rgba(0, 130, 196, 0), inset 0px 0px 0px rgba(255, 255, 255, 0); } }
@-o-keyframes blue {
0%, 100% {
box-shadow: 1px 0px 19px 4px rgba(0, 130, 196, 0.7), inset 0px 0px 10px rgba(255, 255, 255, 0.5); }
50% {
box-shadow: 0px 0px 0px 0px rgba(0, 130, 196, 0), inset 0px 0px 0px rgba(255, 255, 255, 0); } }
@keyframes blue {
0%, 100% {
box-shadow: 1px 0px 19px 4px rgba(0, 130, 196, 0.7), inset 0px 0px 10px rgba(255, 255, 255, 0.5); }
50% {
box-shadow: 0px 0px 0px 0px rgba(0, 130, 196, 0), inset 0px 0px 0px rgba(255, 255, 255, 0); } }
/* Yellow Shadow */
@-moz-keyframes yellow {
0%, 100% {
-moz-box-shadow: 1px 0px 19px 4px #fff503, inset 0px 0px 10px rgba(255, 255, 255, 0.5);
box-shadow: 1px 0px 19px 4px #fff503, inset 0px 0px 10px rgba(255, 255, 255, 0.5); }
50% {
-moz-box-shadow: 0px 0px 0px 0px rgba(255, 245, 3, 0), inset 0px 0px 0px rgba(255, 255, 255, 0);
box-shadow: 0px 0px 0px 0px rgba(255, 245, 3, 0), inset 0px 0px 0px rgba(255, 255, 255, 0); } }
@-webkit-keyframes yellow {
0%, 100% {
-webkit-box-shadow: 1px 0px 19px 4px #fff503, inset 0px 0px 10px rgba(255, 255, 255, 0.5);
box-shadow: 1px 0px 19px 4px #fff503, inset 0px 0px 10px rgba(255, 255, 255, 0.5); }
50% {
-webkit-box-shadow: 0px 0px 0px 0px rgba(255, 245, 3, 0), inset 0px 0px 0px rgba(255, 255, 255, 0);
box-shadow: 0px 0px 0px 0px rgba(255, 245, 3, 0), inset 0px 0px 0px rgba(255, 255, 255, 0); } }
@-o-keyframes yellow {
0%, 100% {
box-shadow: 1px 0px 19px 4px #fff503, inset 0px 0px 10px rgba(255, 255, 255, 0.5); }
50% {
box-shadow: 0px 0px 0px 0px rgba(255, 245, 3, 0), inset 0px 0px 0px rgba(255, 255, 255, 0); } }
@keyframes yellow {
0%, 100% {
box-shadow: 1px 0px 19px 4px #fff503, inset 0px 0px 10px rgba(255, 255, 255, 0.5); }
50% {
box-shadow: 0px 0px 0px 0px rgba(255, 245, 3, 0), inset 0px 0px 0px rgba(255, 255, 255, 0); } }
/* White Shadow */
@-moz-keyframes white {
0%, 100% {
-moz-box-shadow: 1px 0px 19px 4px rgba(255, 255, 255, 0.7), inset 0px 0px 10px rgba(255, 255, 255, 0.5);
box-shadow: 1px 0px 19px 4px rgba(255, 255, 255, 0.7), inset 0px 0px 10px rgba(255, 255, 255, 0.5); }
50% {
-moz-box-shadow: 0px 0px 0px 0px rgba(255, 255, 255, 0), inset 0px 0px 0px rgba(255, 255, 255, 0);
box-shadow: 0px 0px 0px 0px rgba(255, 255, 255, 0), inset 0px 0px 0px rgba(255, 255, 255, 0); } }
@-webkit-keyframes white {
0%, 100% {
-webkit-box-shadow: 1px 0px 19px 4px rgba(255, 255, 255, 0.7), inset 0px 0px 10px rgba(255, 255, 255, 0.5);
box-shadow: 1px 0px 19px 4px rgba(255, 255, 255, 0.7), inset 0px 0px 10px rgba(255, 255, 255, 0.5); }
50% {
-webkit-box-shadow: 0px 0px 0px 0px rgba(255, 255, 255, 0), inset 0px 0px 0px rgba(255, 255, 255, 0);
box-shadow: 0px 0px 0px 0px rgba(255, 255, 255, 0), inset 0px 0px 0px rgba(255, 255, 255, 0); } }
@-o-keyframes white {
0%, 100% {
box-shadow: 1px 0px 19px 4px rgba(255, 255, 255, 0.7), inset 0px 0px 10px rgba(255, 255, 255, 0.5); }
50% {
box-shadow: 0px 0px 0px 0px rgba(255, 255, 255, 0), inset 0px 0px 0px rgba(255, 255, 255, 0); } }
@keyframes white {
0%, 100% {
box-shadow: 1px 0px 19px 4px rgba(255, 255, 255, 0.7), inset 0px 0px 10px rgba(255, 255, 255, 0.5); }
50% {
box-shadow: 0px 0px 0px 0px rgba(255, 255, 255, 0), inset 0px 0px 0px rgba(255, 255, 255, 0); } }
/* Button */
.button {
text-align: center;
padding: 10px 20px;
text-decoration: none;
color: #000;
font-weight: bold;
-webkit-border-radius: 10px;
-moz-border-radius: 10px 0;
border-radius: 10px 0;
margin-right: 20px; }
/* Blue Background */
.blue {
text-shadow: 0px 1px 0px #83e0f7;
background-image: -webkit-linear-gradient(top, #87e0fd, #53cbf1);
background-image: -moz-linear-gradient(top, #87e0fd, #53cbf1);
background-image: -o-linear-gradient(top, #87e0fd, #53cbf1);
background-image: linear-gradient(to bottom, #87e0fd, #53cbf1);
-webkit-animation: blue 2s infinite;
-moz-animation: blue 2s infinite;
-o-animation: blue 2s infinite;
animation: blue 2s infinite; }
/* Yellow Background */
.yellow {
text-shadow: 0px 1px 0px #faffc7;
background-image: -webkit-linear-gradient(top, #fff966, #f3fd80);
background-image: -moz-linear-gradient(top, #fff966, #f3fd80);
background-image: -o-linear-gradient(top, #fff966, #f3fd80);
background-image: linear-gradient(to bottom, #fff966, #f3fd80);
-webkit-animation: yellow 2s infinite;
-moz-animation: yellow 2s infinite;
-o-animation: yellow 2s infinite;
animation: yellow 2s infinite; }
/* White Background */
.white {
text-shadow: 0px 1px 0px #fff;
background-image: -webkit-linear-gradient(top, #ffffff, #cccccc);
background-image: -moz-linear-gradient(top, #ffffff, #cccccc);
background-image: -o-linear-gradient(top, #ffffff, #cccccc);
background-image: linear-gradient(to bottom, #ffffff, #cccccc);
-webkit-animation: white 2s infinite;
-moz-animation: white 2s infinite;
-o-animation: white 2s infinite;
animation: white 2s infinite; }
演示: http ://codepen.io/arbaoui_mehdi/details/yoCnx
注意:我使用动画罗盘插件在compass中应用 css3 动画。