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

How do I add a transition for opacity on hover in css?

  1. User

    How do I add a transition for opacity on hover in css?

  2. Assistant

    To add a transition for opacity on hover in CSS, you can use the following code:

    .element {
      opacity: 1;
      transition: opacity 0.3s ease;
    }
    
    .element:hover {
      opacity: 0.5;
    }
    

    In this code snippet, the transition property is used to specify the transition effect for the opacity property. In this case, the opacity change will take 0.3 seconds to complete and will have an ease timing function. When the element is hovered over, the opacity will change to 0.5 smoothly over the specified duration.