定义链接样式
CSS为一些特殊效果准备了特定的工具,我们称之为“伪类”。其中有几项是我们经常用到的,下面我们就详细介绍一下经常用于定义链接样式的四个伪类,它们分别是:
:link
:visited :hover
:active
因为我们要定义链接样式,所以其中必不可少的就是超级链接中的锚标签--a,锚标签和伪类链接起来书写的方法就是定义链接样式的基础方法,它们的写法如下:
a:link,定义正常链接的样式;
a:visited,定义已访问过链接的样式;
a:hover,定义鼠标悬浮在链接上时的样式;
a:active,定义鼠标点击链接时的样式。
怎样用css设置超链接字体的不同颜色2006-6-7
10:39
yywzya:link
{
text-decoration:
none
color:
#31687E}a:visited
{
color:
#31687E
text-decoration:
none}a:hover
{
color:
#FF0000
text-decoration:
none}a:active
{
color:
#FF0000
text-decoration:
none}a.v1:link
{
text-decoration:
underline
color:
#31687E}a.v1:visited
{
color:
#31687E
text-decoration:
underline}a.v1:hover
{
color:
#333333
text-decoration:
underline}a.v1:active
{
color:
#FF0000
text-decoration:
none}上面四个为默认的超级链接的样式,下面四个为不同颜色的链接样式,不过在链接的时候要调用一下v1的名字如这种格式<a
href="index.asp"
class="v1">首页</a>
Css超链接样式的各属性的顺序不能颠倒,这个顺序非常重要。css中关于超链接的四个属性一般正常顺序为:link,visited,hover,active,即
a:link 链接平常的状态
a:visited 链接被访问过之后
a:hover 鼠标放到链接上的时候
a:active 链接被按下的时候
以下为点过链接后,链接字体变为红色:
a:link { color:#dd3409text-decoration:nonefont-size:13px}/* 超链接的样式 */
a:visited { color:#9f301dtext-decoration:none}
a:visited:hover { color:#9f301dtext-decoration:underline}
a:hover { color:#dd3409text-decoration:underline}
a:active { color:#ff3300text-decoration:underline}