: hover--css:hover pseudo class, applies to the cursor (mouse pointer) pointing to an element, but the style when this element is not activated
- Grammar:
:hover
- CSS version: CSS2
- Citation URL: http://www.dreamdu.com/css/pseudo-class_hover/
- Description
- Applies to a cursor (mouse pointer) that points to an element, but when this element is not activated
- The client (browser) can change the rendering effect according to the user's interaction, CSS provides three pseudo-classes for this situation:
hover
, active
,focus
- The above three pseudo-classes are not mutually exclusive, and one element can be applied to several of them simultaneously.
- : hover pseudo-class for when a user points to an element, such as a user's mouse pointing to a paragraph p. When the user mouse leaves the element, the original style of the restored element is displayed
- Hover, Chinese "stay, hover" meaning
Grammar
:hover
a:hover
a.class:hover
Example
a:hover
{
color
:
yellow
;
background
:
blue
;
font-size
:
small
;
}
p:hover
{
color
:
yellow
;
background
:
blue
;
font-size
:
large
;
}
div:hover
{
color
:
red
;
background
:
lime
;
font-size
:
small
;
}
Internet Explorer does not support elements other than elements of a: hover pseudo-Class
IE6, IE7 (q), IE8 (q) Browsers do not support elements other than elements of a: hover pseudo-class, which can be tested by the example above
sequence of Pseudo-class selectors: L-v-h-a
CSS provides four kinds of pseudo-class settings link color, including: Link,: visited,: hover,: active, their declarations are in a certain order, we will call this order as l-v-h-a, that is, link first, then visited, then hover, Last active, so declared to ensure that the correct style is displayed for hover and active states
Example
a:link
{
color
:
red
;
}
a:visited
{
color
:
green
;
}
a:hover
{
color
:
blue
;
}
a:active
{
color
:
black
;
}