Home>Article>Web Front-end> How to use hover in css
In CSS, hover is used to select the element on which the mouse pointer is floating. The syntax is "label selector:hover{style code;}". Usage: 1. Change the style directly on the suspended element; 2. Change The style of child elements; 3. Change the style of sibling elements; 4. Change the style of nearby elements, etc.
There is a hover attribute in CSS, which can be activated when the mouse is moved up. It can be used to implement some functions similar to js. Next, in the article, we will introduce how to use the hover attribute in detail. I hope it will be helpful to everyone.
[Recommended course:CSS tutorial]
Definition of hover
:hover selector For selecting the element on which the mouse pointer is floating, it applies to all elements
:hover The selector applies to all elements
hover usage
Usage 1: Hover the mouse over the element to change the element style
Example: When the mouse hovers over the font, the font color changes
PHP中文网
Rendering:
This is the most common usage, it just changes the style style
Usage 2: Control the styles of other blocks through hover
This usage can be divided into the following three styles
(1) Control the style of sub-elements
PHP中文网
hover的用法
Rendering:
(2) Control the style of sibling elements
' ' Control sibling elements (sibling elements)
PHP中文网
hover的用法
Rendering:
(3) Control the style of nearby elements
'~' Control nearby elements
PHP中文网
hover的用法
Rendering:
Summary: The above is the entire content of this article, I hope it will be helpful to everyone.
The above is the detailed content of How to use hover in css. For more information, please follow other related articles on the PHP Chinese website!