03
2009-06
学习手札JET1185 人看过

有时候博客经常会提供一些资源供别人下载,但是通常程序中所有的下载链接都只用一个图标来表示.有了新CSS3的属性选择符这项新技术后就可以根据下载文件的不同类型显示不同的图标了.

这里要用到的是:

  1. E [att$=value]{…}  

它的意思用以选取所有以value结尾的元素E.那么可以这样写:

  1. a[href$='.torrent'] {      
  2.  padding5px 20px 5px 0;     
  3.  backgroundtransparent url(icons/icon_torrent.gif) no-repeat center right;     
  4. }     
  5. a[href$='.vcard'] {      
  6.  padding5px 20px 5px 0;     
  7.  backgroundtransparent url(icons/icon_vcard.gif) no-repeat center right;     
  8. }     
  9. a[href$='.exe'] {      
  10.  padding5px 20px 5px 0;     
  11.  backgroundtransparent url(icons/icon_exe.gif) no-repeat center right;     
  12. }     
  13. a[href$='.dmg'], a[href$='.app'] {      
  14.  padding5px 20px 5px 0;     
  15.  backgroundtransparent url(icons/icon_dmg.gif) no-repeat center right;     
  16. }   
通告:http://www.viold.com/Article/243/Trackback.ashx
评论订阅:http://www.viold.com/Article/243/Feeds.ashx

相关文章

评论列表

  1. 2009-06-03 20:07:51 | # | 回复
    没想到CSS还可以这样 以前都是有PHP抑制的,落伍了
  2. 2009-06-07 21:29:03 | # | 回复
    要用的东西,实在是学不完啊!
  3. Gravatar
    JET
    2009-06-12 22:18:54 | # | 回复
    @快乐臭虫 新的技术不断出现,应该还有很多我们没接触到的呢
(必填)
(必填,不会被公开)