- 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>
如果想實現(xiàn)這種效果(我鼠標點“開始動畫”然后p就轉一圈然后fadeOut)該怎么寫呢?
問題解答
回答1:js語法錯誤,取消掉錯誤以后直接用css就可以觸發(fā)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網(wǎng)上例子都太多了先去找例子看回答3:http://www.cnblogs.com/WitNesS/p/4643019.html
相關文章:
1. javascript - Vue 自定義控件v-model雙向綁定2. docker images顯示的鏡像過多,狗眼被亮瞎了,怎么辦?3. docker gitlab 如何git clone?4. linux - mysql源碼安裝遇到的問題5. java - yuicompressor-maven-plugin 合并可用卻不壓縮, 哪配置不對?6. mysql - msyql 判斷字段不為空 簡單方法7. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””8. dockerfile - [docker build image失敗- npm install]9. angular.js使用$resource服務把數(shù)據(jù)存入mongodb的問題。10. docker網(wǎng)絡端口映射,沒有方便點的操作方法么?
