Rotating a background image with CSS3

前端 未结 2 1029
无人及你
无人及你 2021-01-02 03:13

I have a background image that has an arrow that points to the right. When a user clicks on the button, the selected state changes the arrow to point down (using a different

2条回答
  •  爱一瞬间的悲伤
    2021-01-02 03:51

    Here is a rotating css class that I have used to spin a background image:

    .rotating {
      -webkit-animation: rotating-function 1.25s linear infinite;
         -moz-animation: rotating-function 1.25s linear infinite;
          -ms-animation: rotating-function 1.25s linear infinite;
           -o-animation: rotating-function 1.25s linear infinite;
              animation: rotating-function 1.25s linear infinite;
    }
    
    @-webkit-keyframes rotating-function {
      from {
        -webkit-transform: rotate(0deg);
      }
      to {
        -webkit-transform: rotate(360deg);
      }
    }
    
    @-moz-keyframes rotating-function {
      from {
        -moz-transform: rotate(0deg);
      }
      to {
        -moz-transform: rotate(360deg);
      }
    }
    
    @-ms-keyframes rotating-function {
      from {
        -ms-transform: rotate(0deg);
      }
      to {
        -ms-transform: rotate(360deg);
      }
    }
    
    @-o-keyframes rotating-function {
      from {
        -o-transform: rotate(0deg);
      }
      to {
        -o-transform: rotate(360deg);
      }
    }
    
    @keyframes rotating-function {
      from {
        transform: rotate(0deg);
      }
      to {
        transform: rotate(360deg);
      }
    }
    

提交回复
热议问题