有時候我們的博客上經常會提供一些資源供別人下載,但是像是PJBlog中,所有的下載鏈接都只用一個圖標來表示。有了新CSS3的屬性選擇符這項新技術後我們就可以根據下載文件的不同類型顯示不同的圖標了。 這裡我們要用到的是 它的意思用以選取所有以value結尾的元素E。那麼我們可以這樣寫:
E [att$=value]{…}
a[href$='.torrent'] {
padding: 5px 20px 5px 0;
background: transparent url(icons/icon_torrent.gif) no-repeat center right;
}
a[href$='.vcard'] {
padding: 5px 20px 5px 0;
background: transparent url(icons/icon_vcard.gif) no-repeat center right;
}
a[href$='.exe'] {
padding: 5px 20px 5px 0;
background: transparent url(icons/icon_exe.gif) no-repeat center right;
}
a[href$='.dmg'], a[href$='.app'] {
padding: 5px 20px 5px 0;
background: transparent url(icons/icon_dmg.gif) no-repeat center right;
}