Hongmu Notes
Home Language Notes There is an a tag under the li tag. When the mouse is placed on the li tag, how can I make the a tag change color?
Language Notes CSS

There is an a tag under the li tag. When the mouse is placed on the li tag, how can I make the a tag change color?

There is an a tag under the li tag. When the mouse is placed on the li tag, how can I make the a tag change color?

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

微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

css positioning

css positioning Language Notes CSS

Syntax: position: static | relative | absolute | fixed | center | page | sticky Default value: static Applies to: All elements except the display attribute defined as table-column-group | table-column Inheritance: No Animation: No...
👁 119
css vh and vw adaptive

css vh and vw adaptive Language Notes CSS

In the mobile terminal, REM is used to change the root HTML, and the mobile terminal adaptation is realized through a piece of JS. This article uses pure CSS viewport units to self-adapt. Although the current compatibility is not fully acceptable, it does not prevent you from recognizing the power of vw and vh. The implementation of responsive layout relies on media queries (Media Queries). Select the width size of mainstream devices as breakpoints to target...
👁 356

Recommended reading

How to enable error reporting in php?

How to enable error reporting in php? Summary of pitfalls

Simple and efficient method. Add the code directly. <?php error_reporting(E_ALL); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); ?> Just add the following code at the very top of the erroring PHP file, for the current script only...
👁 84
Responsive CNC mechanical power tool holder website template 0028

Responsive CNC mechanical power tool holder website template 0028 Practical Collection Yiyou template

This set of eyoucms responsive templates is suitable for CNC machinery and power tool holder companies. The design style is professional and sophisticated, and can display CNC products, power tool holders and mechanical accessories. It helps CNC machinery companies demonstrate their technical strength online and attract manufacturing customers. Template display Installation instructions Website backend: /login.php Account: admin Password: admin Related articles Yiyou CMS installation FAQ summary Yiyou CMS...
👁 41
(PC+WAP) pbootcms atmospheric environmental protection information news website template Blue Government Association website source code download 0003

(PC+WAP) pbootcms atmospheric environmental protection information news website template Blue Government Association website source code download 0003 Practical Collection pbootcms Template

A blue style atmospheric environmental protection information news website template, developed based on PbootCMS, supports PC and WAP access. This template is very suitable for environmental protection associations, government departments or news and information sites. The page layout is broad and the information level is clear. It integrates multiple functions such as article list, headline recommendation, policy and regulation display, etc. It is an efficient solution for building an environmental information release and industry communication platform. Template display Installation instructions Website backend...
👁 59
Printing and packaging plate making website template 0650

Printing and packaging plate making website template 0650 Practical Collection Yiyou template

An eyoucms website template targeting the printing, packaging and platemaking industries. The design style is professional and practical, and can showcase printing and packaging products, plate making technology, design cases and corporate strength. It helps printing and packaging companies display their brands online and attract brand customers. Template display Installation instructions Website backend: /login.php Account: admin Password: admin Related articles Summary of common problems in Yiyou CMS installation Yiyou C...
👁 50
(Adaptive mobile phone version) Webmaster navigation pbootcms website template html5 navigation website source code download 0604

(Adaptive mobile phone version) Webmaster navigation pbootcms website template html5 navigation website source code download 0604 Practical Collection pbootcms Template

A webmaster navigation and website directory PbootCMS website template, supporting PC and WAP. The design style is simple and practical, suitable for collecting and organizing various website resources and website navigation. It helps webmasters or network practitioners build practical online navigation tools. Template display Installation instructions Website backend: /admin.php Account: admin Password: admin Unzip password: www.4s5.cn Related articles Pbo...
👁 37
unzip LinuxPanel.zip -bash: unzip: command not found

unzip LinuxPanel.zip -bash: unzip: command not found Summary of pitfalls

This error message is because the unzip command line tool is not installed in your Linux system. You can use the following command to install the unzip tool: For Debian/Ubuntu systems: sudo apt-get install unzip For CentOS/RHEL systems: sudo yum install unzip The installation is complete…
👁 188