純CSS3發光按鈕動畫 非常絢麗

2016-02-27    分類:素材庫、網頁按鈕程式碼、指令碼程式碼、首頁精華1人評論發表於2016-02-27

本文由碼農網 – 小峰原創,轉載請看清文末的轉載要求,歡迎參與我們的付費投稿計劃

之前為大家介紹了一款魔幻般的冒泡背景按鈕,這次要分享另外一個非常絢麗的按鈕動畫,我們利用CSS3特性給每一個按鈕渲染不同的顏色,然後讓按鈕出現閃閃發光的動畫特效。雖然這種花哨的按鈕動畫可能應用的地方不多,但這畢竟是用純CSS3實現的,利用起來非常方便,如果你的頁面上需要個性化的按鈕,那麼可以考慮一下使用這款發光按鈕。

HTML程式碼

<div class="wall-of-buttons">
	<a class="large green button">Look at me!</a>
	<a class="large blue button">Click me!</a>
	<a class="large magenta button">Hi ho, Silver!</a>
	<a class="large green button">Look at me!</a>
	<a class="large red button">I'm Glowing!</a>
	<a class="large magenta button">Hi ho, Silver!</a>
	<br />

	<a class="large orange button">Call to Action</a>
	<a class="large magenta button">Hi ho, Silver!</a>
	<a class="large green button">Look at me!</a>
	<a class="large orangellow button">Got clicks?</a>
	<a class="large blue button">Click me!</a>
	<a class="large red button">I'm Glowing!</a>
	<a class="large blue button">Click me!</a>
	<br />

	<a class="large magenta button">Hi ho, Silver!</a>
	<a class="large orangellow button">Got clicks?</a>
	<a class="large red button">I'm Glowing!</a>
	<a class="large orange button">Call to Action</a>
	<a class="large green button">Look at me!</a>
	<a class="large orangellow button">Got clicks?</a>
	<a class="large red button">I'm Glowing!</a>

	<a class="large blue button">Click me!</a>
	<a class="large orangellow button">Got clicks?</a>
	<a class="large blue button">Click me!</a>
	<a class="large red button">I'm Glowing!</a>
	<a class="large orange button">Call to Action</a>
	<a class="large orangellow button">Got clicks?</a>
</div>

CSS程式碼

/* Place all stylesheet code here */
body { background: #333; text-shadow: 0 1px 1px rgba(0,0,0,.5); }

@-webkit-keyframes bigAssButtonPulse {
  from { background-color: #749a02; -webkit-box-shadow: 0 0 25px #333; }
  50% { background-color: #91bd09; -webkit-box-shadow: 0 0 50px #91bd09; }
  to { background-color: #749a02; -webkit-box-shadow: 0 0 25px #333; }
}

@-webkit-keyframes greenPulse {
  from { background-color: #749a02; -webkit-box-shadow: 0 0 9px #333; }
  50% { background-color: #91bd09; -webkit-box-shadow: 0 0 18px #91bd09; }
  to { background-color: #749a02; -webkit-box-shadow: 0 0 9px #333; }
}

@-webkit-keyframes bluePulse {
  from { background-color: #007d9a; -webkit-box-shadow: 0 0 9px #333; }
  50% { background-color: #2daebf; -webkit-box-shadow: 0 0 18px #2daebf; }
  to { background-color: #007d9a; -webkit-box-shadow: 0 0 9px #333; }
}

@-webkit-keyframes redPulse {
  from { background-color: #bc330d; -webkit-box-shadow: 0 0 9px #333; }
  50% { background-color: #e33100; -webkit-box-shadow: 0 0 18px #e33100; }
  to { background-color: #bc330d; -webkit-box-shadow: 0 0 9px #333; }
}

@-webkit-keyframes magentaPulse {
  from { background-color: #630030; -webkit-box-shadow: 0 0 9px #333; }
  50% { background-color: #a9014b; -webkit-box-shadow: 0 0 18px #a9014b; }
  to { background-color: #630030; -webkit-box-shadow: 0 0 9px #333; }
}

@-webkit-keyframes orangePulse {
  from { background-color: #d45500; -webkit-box-shadow: 0 0 9px #333; }
  50% { background-color: #ff5c00; -webkit-box-shadow: 0 0 18px #ff5c00; }
  to { background-color: #d45500; -webkit-box-shadow: 0 0 9px #333; }
}

@-webkit-keyframes orangellowPulse {
  from { background-color: #fc9200; -webkit-box-shadow: 0 0 9px #333; }
  50% { background-color: #ffb515; -webkit-box-shadow: 0 0 18px #ffb515; }
  to { background-color: #fc9200; -webkit-box-shadow: 0 0 9px #333; }
}

a.button {
	-webkit-animation-duration: 2s;
	-webkit-animation-iteration-count: infinite; 
}

.green.button { -webkit-animation-name: greenPulse; -webkit-animation-duration: 3s; }
.blue.button { -webkit-animation-name: bluePulse; -webkit-animation-duration: 4s; }
.red.button { -webkit-animation-name: redPulse; -webkit-animation-duration: 1s; }
.magenta.button { -webkit-animation-name: magentaPulse; -webkit-animation-duration: 2s; }
.orange.button { -webkit-animation-name: orangePulse; -webkit-animation-duration: 3s; }
.orangellow.button { -webkit-animation-name: orangellowPulse; -webkit-animation-duration: 5s; }

.wall-of-buttons { width: 100%; height: 180px; text-align: center; }
.wall-of-buttons a.button { display: inline-block; margin: 0 10px 9px 0; }

本文連結:http://www.codeceo.com/article/pure-css3-shine-buttons.html
本文作者:碼農網 – 小峰
原創作品,轉載必須在正文中標註並保留原文連結和作者等資訊。]

相關文章