简体   繁体   中英

How to rotate css 3d cube in javascript using a button trigger

I have been trying to rotate a css 3-d cube using a button trigger (left) in javascript but I am not sure how animation works in css. I tried this jQuery function where #leftBtn is the button I want to rotate the cube by, and renderLeft/rotate are my attempted classes to rotate the shape. Here is a jsfiddle with the whole code

$("#leftBtn").click(function(event) {    
      $("#front").toggleClass('renderLeft');
      $("#front").toggleClass('rotate');           
        });

Young David Walsh does a nice little rotating cube that I've used before. You'll find that here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM