- css3和jquery的animate在一起怎么沒有想要的效果呢?
問題描述
<!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
相關文章:
1. python - 獲取到的數據生成新的mysql表2. javascript - js 對中文進行MD5加密和python結果不一樣。3. mysql里的大表用mycat做水平拆分,是不是要先手動分好,再配置mycat4. window下mysql中文亂碼怎么解決??5. sass - gem install compass 使用淘寶 Ruby 安裝失敗,出現 4046. python - (初學者)代碼運行不起來,求指導,謝謝!7. 為啥不用HBuilder?8. python - flask sqlalchemy signals 無法觸發9. python的文件讀寫問題?10. 為什么python中實例檢查推薦使用isinstance而不是type?
