CSS比较少用到的伪类样式定义

LMS
1K+ 5

设置个性外链图标,因为不支持ie6,所以一般很少用到,大多数童鞋是用js来实现这样的效果的。

/*先设置所有连接地址图片样式*/
a[href^="http:"]{background:url() no-repeat right top;padding-right:10px;}
/*去除本站链接样式*/
a[href^="http://www.yourdomain.com"], a[href^="http://yourdomain.com"]{background-image:none;padding-right:0;}

/*个性邮件链接样式*/
a[href^="mailto:"]{background:url() no-repeat right top;padding-right:10px;}

/*个性下载链接*/
a[href$=".pdf"]{background:url() no-repeat right top;padding-right:10px;}
a[href$=".doc"]{background:url() no-repeat right top;padding-right:10px;}
a[href$=".rss"].a[href=".rdf"]{background:url() no-repeat right top;padding-right:10px;}
...

/*访问过的链接样式加图,这个支持ie6*/
a:visited{background:url();}

js方法木木同学好像有介绍过,我还没研究到那个程度就不说了。另外,附送个css下拉菜单的样式定义:

/*部分html代码*/
<a href="/" class="list">tuch here to see somthing!<span>you can not see me!</span></a> 

css样式设置

/*make the list link position relative*/
a.list{position:relative;}
/*make the span display none for normal*/
a.list span{display:none;}
/*while touch the link to show the span content,and set the style*/
a.list:hover span{display:block;position:absolute;top:1em;left:2em;border:1px solid #ddd;}
/*fix ie6 bug*/
a.list:hover{font-size:100%;}
THE END

评论 5

  1. sherry
    🏅🏅🏅

    在《精通CSS》上看到过这个呢~~
    不过有很多CSS3的不能在IE上显示,可见浏览器标准不一样很多时候障碍了CSS继续发展的脚步,当然了,嘿嘿,这是个趋势,无法阻挡?

  2. that5
    🏆🏅🏅

    学习了, :grin:

  3. 万戈
    🏆🏅

    额。。。我还没到那个程度,只能掌握一些最最常用的CSS

    1. 其实这个不算什么程度,只是不支持ie,而且有更好的js解决方法,所以就被忽略了,我也是随便摘抄出来的。

发表评论

Submit