Last active
July 31, 2017 20:13
-
-
Save ajuliano/39ba3ff46b3bfcdab88c to your computer and use it in GitHub Desktop.
Make SVG clickable in a-tag and with image fallback
This file contains hidden or 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
/** | |
* Make SVG clickable in a-tag and with image fallback (perfect for logotypes) | |
* | |
* HTML: | |
* <a href="http://dystonia-europe.org" target="_blank" class="u--svg-inside"> | |
* <object data="svg-image.svg" type="image/svg+xml"> <img src="fallback-image.png" /> </object> | |
* </a> | |
* | |
*/ | |
.u--svg-inside { | |
position: relative; | |
display: inline-block; | |
&:after { | |
content: ""; | |
position: absolute; | |
top: 0; | |
right: 0; | |
bottom: 0; | |
left: 0; | |
} | |
object { | |
width: 100%; // Optional | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Implemented on Codepen for you.
http://codepen.io/ballerton/pen/XXEVeY