css定义超级连接样式的伪类,CSS比较少用到的伪类样式定义

本文介绍如何使用CSS为不同类型的链接设置图标,并展示了一个简单的下拉菜单样式实现方法。包括外部链接、电子邮件链接、文件下载链接等的个性化图标设置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

设置个性外链图标,因为不支持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%;}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值