css教程:CSS伪类_CSS教程

编辑Tag赚U币
教程Tag:暂无Tag,欢迎添加,赚取U币!
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 实例:
代码调试框 [www.mb5u.com]

[ 可先修改部分代码 再运行查看效果 ]



Hyperlink 2
如何给超级连接加上其他样式

This example demonstrates how to add other styles to hyperlinks.
Examples 实例:
代码调试框 [www.mb5u.com]

[ 可先修改部分代码 再运行查看效果 ]


The syntax of pseudo-classes:
伪类语法:
示例代码 [www.mb5u.com]
selector:pseudo-class {property: value}


CSS classes can also be used with pseudo-classes:
类也可以使用伪类:
示例代码 [www.mb5u.com]
selector.class:pseudo-class {property: value}


锚点伪类 Anchor Pseudo-classes
A 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:
示例代码 [www.mb5u.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类组合使用:
示例代码 [www.mb5u.com]
a.red:visited {color: #FF0000}
<a class="red" href="http://www.mb5u.com/">CSS Syntax</a>

If the link in the example above has been visited, it will be displayed in red.
假如上面的连接已经被访问过了,它就会显示为红色。

来源:无忧整理//所属分类:CSS教程/更新时间:2006-11-11
相关CSS教程