CSS3 過渡與動畫

來源:互聯網
上載者:User

標籤:style   http   io   ar   strong   sp   on   代碼   html   

滑鼠懸浮炫光效果:http://demo.qpdiy.com/hxw/CSS3/button-light.html

在網頁上實現這種動作效果有三種方法:

首先是JS,可以用jquery的animate事件實現,如果不想用JS的話可以通過css3實現

過渡:.button:hover i { left:100%; -webkit-transition:.5s; -moz-transition:.5s; transition:.5s;}

————當滑鼠移開後,i會直接變到原來的位置,如果 transition:.5s;寫在原來的i上,則滑鼠移開後會快速退回到原來位置

動畫:

.button:hover i { -webkit-animation: butleft 0.5s; -moz-animation: butleft 0.5s; -o-animation: butleft 0.5s; animation:butleft 0.5s; }

@keyframes butleft { from {left:-100px;} to {left:100px;} }

@-moz-keyframes butleft /* Firefox */ { from {left:-100px;} to {left:100px;} }

@-webkit-keyframes butleft /* Safari and Chrome */ { from {left:-100px;} to {left:100px;} }

@-o-keyframes butleft /* Opera */ { from {left:-100px;} to {left:100px;} }

CSS3 動畫比過渡來說代碼量是多了一些,但是它能從0%到100%之間直接定義不同的動作

 

注意:

1、<i>元素裡面如果沒有內容的話事件是綁定不上的,必須要綁定在button存在的標籤內;

2、hover事件不能用on來綁定

CSS3 過渡與動畫

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.