gpt-3.5-turbo-0125· OpenAI
WildChat-4.8M (AI2)
How do I add a transition for opacity on hover in css?
- User
How do I add a transition for opacity on hover in css?
- 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
transitionproperty is used to specify the transition effect for theopacityproperty. 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.