旋轉動畫正在工作。圖像的大小正在改變,但圖像的翻譯根本不起作用。我不知道為什么,我單獨嘗試了它,但它仍然不起作用。我還查看了十幾個其他人翻譯他們項目的示例,包括 codepen 上的示例。我的代碼幾乎是準確的,但它沒有產(chǎn)生任何結果。為什么會發(fā)生這種情況,我該如何解決?感謝您的任何建議或幫助。$("#toolbar").on("click", function() { const speed = 500; if ($('#toolbar').css("width") == "75px") { $('#toolbar').css("transform", "translateX(250px)"); $('#toolbar').css("width", "70px"); // change toolbar rotation $("#toolbar").animate({ deg: 0 }, { duration: speed, queue: false, step: function(now) { $(this).css({ transform: "rotate(" + now + "deg)" }) } }) } else { $('#toolbar').css("transform", "translateX(250px)"); $('#toolbar').css("width", "75px"); // change toolbar rotation $("#toolbar").animate({ deg: 90 }, { duration: speed, queue: false, step: function(now) { $(this).css({ transform: "rotate(" + now + "deg)" }) } }) }});#toolbar { width:70px; height:70px; transition: transform 500ms linear;}<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><img id="toolbar" alt="toolbar" src="http://pngimg.com/uploads/cursor/cursor_PNG67.png">
為什么我的翻譯動畫不起作用?
尚方寶劍之說
2021-08-20 18:00:55