Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· OpenAIAi2 WildChat-4.8M (AI2)

write a spin animation in css

  1. User

    write a spin animation in css

  2. Assistant

    To create a spin animation in CSS, you can use the @keyframes rule to define the rotation and duration of the animation, and then apply it to an element using the animation property.

    Here is an example of a spin animation that rotates a div element 360 degrees over a duration of 2 seconds:

    .spin {
      animation: spin 2s linear infinite;
    }
    
    @keyframes spin {
      0% {
        transform: rotate(0deg);
      }
      
      100% {
        transform: rotate(360deg);
      }
    }
    

    To use this animation, simply add the class “spin” to any HTML element you want to spin:

    <div class="spin">Hello World</div>
    

    This will create a continuous spin animation that rotates the element indefinitely. You can customize the animation by adjusting the duration, the timing function, or the angle of rotation.