大家都知道想要设置统一的连接样式,只要在css文件中设置a:link,a:visited,ahover,a:active就行了。可以设置全局的连接样式。比如:
a:link,a:visited{
text-decoration:underline;
color:#629300;
}
a:hover,a:active{
text-decoration:none;
}
但是有的时候为了一些效果,想要设置一些针对某些特殊连接的样式,就需要在CSS中继续进行加工了。常用的方式有:
1.增加连接样式命名:
a.red:link { color: #FF0000; text-decoration: none;}
a.red:visited { color: #FF0000; text-decoration: none;}
a.red:hover { color: #606060; text-decoration: underline;}
a.red:active { color: #606060; text-decoration: underline;}
2.div定义命名:
div.other a:link,a:visited,a:hover,a:active{ text-decoration:none;
color:#eefffe;
font-size:28;
}
以上两种方式可以结合使用,在同一个html文件中调用的代码如下:
<a href=”http://as30.com”>三十而立</a>/*默认的连接样式*/
<a class=”red” href=”http://as30.com”>三十而立</a>/*第一种设置连接样式的方式*/
<div class=”other”>
<a class=”other” herf=”http://www.as30.com”>普洱和潘多拉的博客</a>
</div>/*第二种设置连接样式的方式*/
变化的方式自己可以变通掌握。呵呵~有问题欢迎一起探讨。