Home >Web Front-end >Front-end Q&A >How to set up css hover

How to set up css hover

藏色散人
藏色散人Original
2021-04-29 14:04:163602browse

css hover is a selector used to select the element on which the mouse pointer floats. The setting syntax of this selector is such as "a:hover{background-color:yellow;}".

How to set up css hover

The operating environment of this article: Windows7 system, HTML5&&CSS3 version, Dell G3 computer.

:hover selector is used to select the element on which the mouse pointer is floating.

Tip: The :hover selector can be used on all elements, not just links.

Tips: The :link selector sets the style of links pointing to pages that have not been visited, the :visited selector is used to set links to pages that have been visited, and the :active selector is used for active links.

Note: In the CSS definition, :hover must be placed after :link and :visited (if present) for the style to take effect.

Example

Select the element the mouse pointer is floating on and set its style:

Code:

<!DOCTYPE html>
<html>
<head>
<style>
a:hover
{
background-color:yellow;
}
</style>
</head>
<body>

<a href="http://www.w3school.com.cn">W3Sschool</a>
<a href="http://www.google.com">Google</a>
<a href="http://www.wikipedia.org">Wikipedia</a>

<p><b>注释:</b>:hover 选择器鼠标指针在其上浮动的链接设置样式。</p>

</body>
</html>

Effect:

How to set up css hover

For more detailed HTML/CSS knowledge, please visit the CSS Video Tutorial column!

The above is the detailed content of How to set up css hover. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn