Home >Web Front-end >CSS Tutorial >Why Isn't My Hover Menu Background Transitioning Smoothly?
Question:
Despite using CSS transitions, the background color of menu items does not change smoothly on hover. Here's the relevant CSS:
#content #nav a:hover { color: black; background-color: #AD310B; -moz-transition: all 1s ease-in; -webkit-transition: all 1s ease-in; -o-transition: all 1s ease-in; transition: all 1s ease-in; }
Answer:
Browser support is essential for transitions to function correctly. As of the time of writing, transitions are supported in:
To achieve the desired fade effect, consider the following CSS:
a { background-color: #FF0; } a:hover { background-color: #AD310B; -webkit-transition: background-color 1000ms linear; -ms-transition: background-color 1000ms linear; transition: background-color 1000ms linear; }
This ensures that background color transitions work in supported browsers, creating a smooth fading effect when hovering over menu links:
<a>Navigation Link</a>
The above is the detailed content of Why Isn't My Hover Menu Background Transitioning Smoothly?. For more information, please follow other related articles on the PHP Chinese website!