CSS:hover选择器_html/css_WEB-ITnose

WBOY
Release: 2016-06-21 09:11:45
Original
2149 people have browsed it

在鼠标浮动在元素上后,元素的样式改变的情况下,:hover选择器是一种很好的选择。接下来看看:hover的相关定义及用法。

:hover选择器用于选择鼠标指针浮动在上面的元素。

注意:

1.一开始我以为:hover选择器只可用于链接上,但事实上,它竟可以用于所有的元素。
2.在CSS定义中,:hover必须位于:link和:visited之后(如果存在的话),这样才可以生效。

下面来看一段使用的代码。

<!DOCTYPE html><html><head>    <meta charset="utf-8"/>    <style>        p:hover{color:red;}        /*第二个注意事项,可以改变a:hover的位置来验证*/        a:link    {color:blue;}        a:visited {color:blue;}        a:hover   {color:red;}        a:active  {color:yellow;}    </style><head><body>    <p>当鼠标滑过时,字体变红</p>    <a href="http://segmentfault.com/blog/sexyMustaches">sexyMustaches</a></body></html>
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template