DIV CSS 佈局教程網

您现在的位置: DIV+CSS佈局教程網 >> 網頁腳本 >  >> CSS入門知識 >> DIV十CSS布局 >> 布局實例
CSS3 按鈕動畫效果實作
編輯:布局實例     

使用 CSS3 可以為按鈕加入圓角、陰影與動畫。以下範例以深色按鈕為基礎,在 hover 時觸發綠色脈衝效果。

按鈕基礎樣式

.button, .button:visited {
  background: #222 url(overlay.png) repeat-x;
  display: inline-block;
  padding: 5px 10px 6px;
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

Hover 動畫設定

.button:hover {
  background-color: #111;
  animation-duration: 2s;
  animation-timing-function: ease-out;
  animation-iteration-count: infinite;
}

定義脈衝動畫

@-webkit-keyframes greenPulse {
  from { background-color: #91bd09; box-shadow: 0 0 9px #333; }
  50% { background-color: #B4E02C; box-shadow: 0 0 18px #91bd09; }
  to { background-color: #91bd09; box-shadow: 0 0 9px #333; }
}
.green.button:hover { -webkit-animation-name: greenPulse; }

HTML 結構可將按鈕套用在 a 或 input 元素上,並加上 button、green 等 class。不同瀏覽器對動畫支援程度不同,正式環境建議加上必要的瀏覽器前綴並測試。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved