How to Highlight Active Menu Items and Dim Non-Active Ones
In this code snippet, we encounter a scenario where we want to dim the opacity of all menu items (
CSS Solution
To achieve this effect, we utilize CSS to dynamically adjust the opacity of the menu items:
ul:hover li { opacity: 0.5; } ul li:hover { opacity: 1; }
Explanation:
Example
Consider the following HTML and CSS code:
<ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> </ul> <style> li { float: left; width: 33.33%; line-height: 50px; background: gray; list-style-type: none; } ul:hover li { opacity: 0.5; } ul li:hover { opacity: 1; } </style>
When you hover over the
The above is the detailed content of How to Highlight Active Menu Items While Dimming Inactive Ones with CSS?. For more information, please follow other related articles on the PHP Chinese website!