CSS pseudo-classes are used to add special effects to some selectors.
CSS伪类可用来给一些选择器加上非凡效果。Hyperlink
如何在文档内给超级连接加上不同的颜色This example demonstrates how to add different colors to a hyperlink in a document.
Examples 实例:
Source Code to Run
[www.21shipin.com] Hyperlink 2
如何给超级连接加上其他样式This example demonstrates how to add other styles to hyperlinks.
Examples 实例:
Source Code to Run
[www.21shipin.com]The syntax of pseudo-classes:
伪类语法:
Example Source Code
[www.21shipin.com]selector:pseudo-class {property: value}
CSS classes can also be used with pseudo-classes:
类也可以使用伪类:
Example Source Code
[www.21shipin.com]selector.class:pseudo-class {property: value}
锚点伪类 Anchor Pseudo-classesA link that is active, visited, unvisited, or when you mouse over a link can all be displayed in different ways in a CSS-supporting browser:
当一个连接处于 活动,被访问,未访问或是当你鼠标移动到上面的时候都可以给它以不同的方式来表现,前提是浏览器支持CSS:
Example Source Code
[www.21shipin.com]a:link {color: #FF0000} /* unvisited link */
a:visited {color: #00FF00} /* visited link */
a:hover {color: #FF00FF} /* mouse over link */
a:active {color: #0000FF} /* selected link */
Note: a:hover MUST come after a:link and a:visited in the CSS definition in order to be effective!!
注重 a:hover 必须在a:link和 a:visited后出现,要有顺序才能正常显示效果!
Note: a:active MUST come after a:hover in the CSS definition in order to be effective!!
注重: CSS中a:active必须出现在a:hover定义后才能有效果!
Pseudo-classes and CSS Classes
伪类和CSS类Pseudo-classes can be combined with CSS classes:
伪类可以与CSS类组合使用:
Example Source Code
[www.21shipin.com]a.red:visited {color: #FF0000}
<a class=\"red\" href=\"http://www.21shipin.com/\">CSS Syntax</a>
If the link in the example above has been visited, it will be displayed in red.
假如上面的连接已经被访问过了,它就会显示为红色。