jquery rotate image onclick

前端 未结 7 694
难免孤独
难免孤独 2020-12-17 10:30

I am trying to achieve this (90 degree rotation), but it fails without errors. This image is within a TAG where it has already a toggle jque

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-17 11:27

    Depending on which browser versions you need to support, you could try CSS tranforms.

    First, define a CSS class like this:

    .rotated {
      transform: rotate(90deg);
      -ms-transform: rotate(90deg); /* IE 9 */
      -moz-transform: rotate(90deg); /* Firefox */
      -webkit-transform: rotate(90deg); /* Safari and Chrome */
      -o-transform: rotate(90deg); /* Opera */
    }
    

    And then you can use jQuery to add the class when clicking the link:

    
    

提交回复
热议问题