To achieve when the mouse is placed on li When labeling, let the internal a To change the label color, you can use CSS :hover Selectors combine descendant selectors. Here's a simple example:
Assume your HTML structure is as follows:
<ul>
<li><a href="#">链接1</a></li>
<li><a href="#">链接2</a></li>
<!-- 更多 li 和 a 标签 -->
</ul>You can use the following CSS to achieve mouseover on li On time a The effect of label discoloration:
li:hover a {
color: red; /* 你可以更改为你想要的任何颜色 */
}This CSS rule means: when the mouse hovers over li element, select the li all within the element a elements and change their color to red.
Note that this approach assumes a tag is li The direct child element of the label. If there are more nested elements between them, you may need to adjust the selector to select correctly a label. For example, if a The label is wrapped in a div , then the selector may need to be changed to li:hover div a。