Created
April 25, 2012 04:56
-
-
Save magemore/2486543 to your computer and use it in GitHub Desktop.
File format-dependent link styles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* external links | |
The ^= specifies that we want to match links that begin with the http:// | |
*/ | |
a[href^="http://"]{ | |
padding-right: 20px; | |
background: url(external.gif) no-repeat center right; | |
} | |
/* emails | |
The ^= specifies that we want to match links that begin with the mailto: | |
*/ | |
a[href^="mailto:"]{ | |
padding-right: 20px; | |
background: url(email.png) no-repeat center right; | |
} | |
/* pdfs | |
The $= specifies that we want to match links whose hrefs end with ".pdf". | |
*/ | |
a[href$=".pdf"]{ | |
padding-right: 20px; | |
background: url(pdf.png) no-repeat center right; | |
} | |
/* zip | |
Same as above but for zip files and it adds an icon at the right of the link. Therefore the :after | |
*/ | |
a[href$=".zip"]:after{ | |
content: url(icons/zip.png); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This snippet shows small icons next to a link that’s of a certain file format. The following has file format-dependent link styles for email, pdf, and zip file links. You can add more: just copy/paste one chunk and add your own extension (ex. “.mp3″).