How to Implement Smooth Background-Color Transitions for Menu Hovers
Achieving a transition effect for background color on hover is a common styling requirement, but can sometimes present challenges. Here, we explore a solution to this problem.
Original Code
The provided CSS code attempts to implement background color transitions, but encounters an issue:
#content #nav a:hover { color: black; background-color: #AD310B; /* Transition properties */ }
Solution
To enable transitions, you need to ensure support across various browsers. The following updated code should provide the desired fading effect:
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; }
Explanation
Example
<a>Navigation Link</a>
The above is the detailed content of How to Smoothly Transition Background Colors on Menu Hover?. For more information, please follow other related articles on the PHP Chinese website!