您的位置:首頁技術文章
文章詳情頁

- css3和jquery的animate在一起怎么沒有想要的效果呢?

瀏覽:59日期:2023-08-07 16:56:01

問題描述

<!DOCTYPE html><html><head><script src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'></script><script> $(document).ready(function(){ $('button').click(function(){ $('p').animate({ width:’200px’, height:’200px’, transform:’rotate(360deg)’; -webkit-transform:’rotate(360deg)’; }); });});</script></head><body><button>開始動畫</button><p style='width:100px; height:100px; background:yellow; transition:width 2s, height 2s; -webkit-transition:width 2s, height 2s, -webkit-transform 2s;'></p></body></html>

如果想實現這種效果(我鼠標點“開始動畫”然后p就轉一圈然后fadeOut)該怎么寫呢?

問題解答

回答1:

js語法錯誤,取消掉錯誤以后直接用css就可以觸發css3動畫

$('button').click(function(){ $('p').css({ ’width’:’200px’, ’height’:’200px’, ’transform’:’rotate(360deg)’, ’-webkit-transform’:’rotate(360deg)’ }); });

當然了,還是不建議jquery動畫和css3動畫混用,幫你用css3寫了一個效果,你看著改一下吧http://jsfiddle.net/Fmdrx/

回答2:JS語法錯誤jQuery的animate方法和css3 animation完全是兩個不一樣的東西,不要混用無論是jQ的animate還是css3的animation網上例子都太多了先去找例子看回答3:

http://www.cnblogs.com/WitNesS/p/4643019.html

標簽: CSS
相關文章:
国产综合久久一区二区三区