JAVA、PHP、前端、APP、网站开发 - 开发技术学习

开发技术学习 » 前端设计 » 纯CSS3实现发光动画按钮特效

纯CSS3实现发光动画按钮特效

此文被围观4181日期: 2015-01-24 分类 : 前端设计  标签:  ····

这是一款基于纯CSS3的发光按钮,按钮发光的颜色是随机的,这样一排按钮就显得五彩缤纷,非常绚丽。之前我们也介绍过不少样式很独特的CSS3按钮,比如纯CSS3 3D开关按钮纯CSS3实现动感弹性按钮等,都非常不错,也有HTML5动画按钮,大家可以自己看看。

在线地址:

http://www.html5tricks.com/demo/pure-css3-shine-button/index.html

效果图:

背景图:

<!DOCTYPE html>
<html>

<head>

  <meta charset="UTF-8">

  <title>纯CSS3实现发光按钮特效DEMO演示</title>

    <style>
body {
  background: #333333 url(css/classy_fabric.png);
  margin: 0;
}

#c {
  position: absolute;
  top: 50%;
  left: 50%;
  margin-left: -355px;
}

.s {
  position: relative;
  border-radius: 50%;
  background: #333333;
  float: left;
  margin-left: 20px;
  box-shadow: inset -1px 1px 4px 2px #444, inset 1px -1px 4px 2px #222;
  -webkit-transition: all 1s;
  -moz-transition: all 1s;
  transition: all 1s;
}
.s:nth-child(n):hover {
  -webkit-animation: bs2 linear 1s 1s infinite, bs2-in 1s;
  -moz-animation: bs2 linear 1s 1s infinite, bs2-in 1s;
  animation: bs2 linear 1s 1s infinite, bs2-in 1s;
}

.s:nth-child(1) {
  width: 20px;
  height: 20px;
  margin-top: -10px;
  -webkit-animation: bs linear 2s 0.5s infinite;
  -moz-animation: bs linear 2s 0.5s infinite;
  animation: bs linear 2s 0.5s infinite;
}

.s:nth-child(2) {
  width: 30px;
  height: 30px;
  margin-top: -15px;
  -webkit-animation: bs linear 2s 0.7s infinite;
  -moz-animation: bs linear 2s 0.7s infinite;
  animation: bs linear 2s 0.7s infinite;
}

.s:nth-child(3) {
  width: 40px;
  height: 40px;
  margin-top: -20px;
  -webkit-animation: bs linear 2s 0.9s infinite;
  -moz-animation: bs linear 2s 0.9s infinite;
  animation: bs linear 2s 0.9s infinite;
}

.s:nth-child(4) {
  width: 50px;
  height: 50px;
  margin-top: -25px;
  -webkit-animation: bs linear 2s 1.1s infinite;
  -moz-animation: bs linear 2s 1.1s infinite;
  animation: bs linear 2s 1.1s infinite;
}

.s:nth-child(5) {
  width: 60px;
  height: 60px;
  margin-top: -30px;
  -webkit-animation: bs linear 2s 1.3s infinite;
  -moz-animation: bs linear 2s 1.3s infinite;
  animation: bs linear 2s 1.3s infinite;
}

.s:nth-child(6) {
  width: 70px;
  height: 70px;
  margin-top: -35px;
  -webkit-animation: bs linear 2s 1.5s infinite;
  -moz-animation: bs linear 2s 1.5s infinite;
  animation: bs linear 2s 1.5s infinite;
}

.s:nth-child(7) {
  width: 60px;
  height: 60px;
  margin-top: -30px;
  -webkit-animation: bs linear 2s 1.7s infinite;
  -moz-animation: bs linear 2s 1.7s infinite;
  animation: bs linear 2s 1.7s infinite;
}

.s:nth-child(8) {
  width: 50px;
  height: 50px;
  margin-top: -25px;
  -webkit-animation: bs linear 2s 1.9s infinite;
  -moz-animation: bs linear 2s 1.9s infinite;
  animation: bs linear 2s 1.9s infinite;
}

.s:nth-child(9) {
  width: 40px;
  height: 40px;
  margin-top: -20px;
  -webkit-animation: bs linear 2s 2.1s infinite;
  -moz-animation: bs linear 2s 2.1s infinite;
  animation: bs linear 2s 2.1s infinite;
}

.s:nth-child(10) {
  width: 30px;
  height: 30px;
  margin-top: -15px;
  -webkit-animation: bs linear 2s 2.3s infinite;
  -moz-animation: bs linear 2s 2.3s infinite;
  animation: bs linear 2s 2.3s infinite;
}

.s:nth-child(11) {
  width: 20px;
  height: 20px;
  margin-top: -10px;
  -webkit-animation: bs linear 2s 2.5s infinite;
  -moz-animation: bs linear 2s 2.5s infinite;
  animation: bs linear 2s 2.5s infinite;
}

@-webkit-keyframes bs {
  0% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 0px 0 #b2ff1a;
  }

  50% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 20px 0 #1affff;
  }

  100% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 0px 0 #b2ff1a;
  }
}
@-moz-keyframes bs {
  0% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 0px 0 #b2ff1a;
  }

  50% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 20px 0 #1affff;
  }

  100% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 0px 0 #b2ff1a;
  }
}
@-o-keyframes bs {
  0% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 0px 0 #b2ff1a;
  }

  50% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 20px 0 #1affff;
  }

  100% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 0px 0 #b2ff1a;
  }
}
@keyframes bs {
  0% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 0px 0 #b2ff1a;
  }

  50% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 20px 0 #1affff;
  }

  100% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 0px 0 #b2ff1a;
  }
}
@-webkit-keyframes bs2-in {
  0% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 10px 0 #bbff33;
  }

  100% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 0px 0 #ff3333;
  }
}
@-moz-keyframes bs2-in {
  0% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 10px 0 #bbff33;
  }

  100% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 0px 0 #ff3333;
  }
}
@-o-keyframes bs2-in {
  0% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 10px 0 #bbff33;
  }

  100% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 0px 0 #ff3333;
  }
}
@keyframes bs2-in {
  0% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 10px 0 #bbff33;
  }

  100% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 0px 0 #ff3333;
  }
}
@-webkit-keyframes bs2 {
  0% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 0px 0 #ff3333;
  }

  50% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 10px 0 #ffbb33;
  }

  100% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 0px 0 #ff3333;
  }
}
@-moz-keyframes bs2 {
  0% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 0px 0 #ff3333;
  }

  50% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 10px 0 #ffbb33;
  }

  100% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 0px 0 #ff3333;
  }
}
@-o-keyframes bs2 {
  0% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 0px 0 #ff3333;
  }

  50% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 10px 0 #ffbb33;
  }

  100% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 0px 0 #ff3333;
  }
}
@keyframes bs2 {
  0% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 0px 0 #ff3333;
  }

  50% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 10px 0 #ffbb33;
  }

  100% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 0px 0 #ff3333;
  }
}

</style>

    <script src="js/prefixfree.min.js"></script>

</head>

<body>
<div style="text-align:center;clear:both;">
<script src="/gg_bd_ad_720x90.js" type="text/javascript"></script>
<script src="/follow.js" type="text/javascript"></script>
</div>
  <div id='c'>
  <div class='s'></div>
  <div class='s'></div>
  <div class='s'></div>
  <div class='s'></div>
  <div class='s'></div>
  <div class='s'></div>
  <div class='s'></div>
  <div class='s'></div>
  <div class='s'></div>
  <div class='s'></div>
  <div class='s'></div>
</div>

  <script src='http://codepen.io/assets/libs/fullpage/jquery.js'></script>

  <script src="js/index.js"></script>

</body>

</html>
body {
  background: #333333 url(/images/classy_fabric.png);
  margin: 0;
}

#c {
  position: absolute;
  top: 50%;
  left: 50%;
  margin-left: -355px;
}

.s {
  position: relative;
  border-radius: 50%;
  background: #333333;
  float: left;
  margin-left: 20px;
  box-shadow: inset -1px 1px 4px 2px #444, inset 1px -1px 4px 2px #222;
  -webkit-transition: all 1s;
  -moz-transition: all 1s;
  transition: all 1s;
}
.s:nth-child(n):hover {
  -webkit-animation: bs2 linear 1s 1s infinite, bs2-in 1s;
  -moz-animation: bs2 linear 1s 1s infinite, bs2-in 1s;
  animation: bs2 linear 1s 1s infinite, bs2-in 1s;
}

.s:nth-child(1) {
  width: 20px;
  height: 20px;
  margin-top: -10px;
  -webkit-animation: bs linear 2s 0.5s infinite;
  -moz-animation: bs linear 2s 0.5s infinite;
  animation: bs linear 2s 0.5s infinite;
}

.s:nth-child(2) {
  width: 30px;
  height: 30px;
  margin-top: -15px;
  -webkit-animation: bs linear 2s 0.7s infinite;
  -moz-animation: bs linear 2s 0.7s infinite;
  animation: bs linear 2s 0.7s infinite;
}

.s:nth-child(3) {
  width: 40px;
  height: 40px;
  margin-top: -20px;
  -webkit-animation: bs linear 2s 0.9s infinite;
  -moz-animation: bs linear 2s 0.9s infinite;
  animation: bs linear 2s 0.9s infinite;
}

.s:nth-child(4) {
  width: 50px;
  height: 50px;
  margin-top: -25px;
  -webkit-animation: bs linear 2s 1.1s infinite;
  -moz-animation: bs linear 2s 1.1s infinite;
  animation: bs linear 2s 1.1s infinite;
}

.s:nth-child(5) {
  width: 60px;
  height: 60px;
  margin-top: -30px;
  -webkit-animation: bs linear 2s 1.3s infinite;
  -moz-animation: bs linear 2s 1.3s infinite;
  animation: bs linear 2s 1.3s infinite;
}

.s:nth-child(6) {
  width: 70px;
  height: 70px;
  margin-top: -35px;
  -webkit-animation: bs linear 2s 1.5s infinite;
  -moz-animation: bs linear 2s 1.5s infinite;
  animation: bs linear 2s 1.5s infinite;
}

.s:nth-child(7) {
  width: 60px;
  height: 60px;
  margin-top: -30px;
  -webkit-animation: bs linear 2s 1.7s infinite;
  -moz-animation: bs linear 2s 1.7s infinite;
  animation: bs linear 2s 1.7s infinite;
}

.s:nth-child(8) {
  width: 50px;
  height: 50px;
  margin-top: -25px;
  -webkit-animation: bs linear 2s 1.9s infinite;
  -moz-animation: bs linear 2s 1.9s infinite;
  animation: bs linear 2s 1.9s infinite;
}

.s:nth-child(9) {
  width: 40px;
  height: 40px;
  margin-top: -20px;
  -webkit-animation: bs linear 2s 2.1s infinite;
  -moz-animation: bs linear 2s 2.1s infinite;
  animation: bs linear 2s 2.1s infinite;
}

.s:nth-child(10) {
  width: 30px;
  height: 30px;
  margin-top: -15px;
  -webkit-animation: bs linear 2s 2.3s infinite;
  -moz-animation: bs linear 2s 2.3s infinite;
  animation: bs linear 2s 2.3s infinite;
}

.s:nth-child(11) {
  width: 20px;
  height: 20px;
  margin-top: -10px;
  -webkit-animation: bs linear 2s 2.5s infinite;
  -moz-animation: bs linear 2s 2.5s infinite;
  animation: bs linear 2s 2.5s infinite;
}

@-webkit-keyframes bs {
  0% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 0px 0 #b2ff1a;
  }

  50% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 20px 0 #1affff;
  }

  100% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 0px 0 #b2ff1a;
  }
}
@-moz-keyframes bs {
  0% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 0px 0 #b2ff1a;
  }

  50% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 20px 0 #1affff;
  }

  100% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 0px 0 #b2ff1a;
  }
}
@-o-keyframes bs {
  0% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 0px 0 #b2ff1a;
  }

  50% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 20px 0 #1affff;
  }

  100% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 0px 0 #b2ff1a;
  }
}
@keyframes bs {
  0% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 0px 0 #b2ff1a;
  }

  50% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 20px 0 #1affff;
  }

  100% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 0px 0 #b2ff1a;
  }
}
@-webkit-keyframes bs2-in {
  0% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 10px 0 #bbff33;
  }

  100% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 0px 0 #ff3333;
  }
}
@-moz-keyframes bs2-in {
  0% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 10px 0 #bbff33;
  }

  100% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 0px 0 #ff3333;
  }
}
@-o-keyframes bs2-in {
  0% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 10px 0 #bbff33;
  }

  100% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 0px 0 #ff3333;
  }
}
@keyframes bs2-in {
  0% {
    box-shadow: inset -1px 1px 3px 2px #444444, inset 1px -1px 3px 2px #222222, 0 0 10px 0 #bbff33;
  }

  100% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 0px 0 #ff3333;
  }
}
@-webkit-keyframes bs2 {
  0% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 0px 0 #ff3333;
  }

  50% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 10px 0 #ffbb33;
  }

  100% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 0px 0 #ff3333;
  }
}
@-moz-keyframes bs2 {
  0% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 0px 0 #ff3333;
  }

  50% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 10px 0 #ffbb33;
  }

  100% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 0px 0 #ff3333;
  }
}
@-o-keyframes bs2 {
  0% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 0px 0 #ff3333;
  }

  50% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 10px 0 #ffbb33;
  }

  100% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 0px 0 #ff3333;
  }
}
@keyframes bs2 {
  0% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 0px 0 #ff3333;
  }

  50% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 10px 0 #ffbb33;
  }

  100% {
    box-shadow: inset -1px 1px 5px 2px #444444, inset 1px -1px 5px 2px #222222, 0 0 0px 0 #ff3333;
  }
}


站点声明:部分内容源自互联网,为传播信息之用,如有侵权,请联系我们删除。

© Copyright 2011-2024 www.kfju.com. All Rights Reserved.
超级字帖 版权所有。蜀ICP备12031064号