Skip to content

Instantly share code, notes, and snippets.

@nofilenamed
Forked from ajuliano/Clickable svg in a-tag
Created January 10, 2016 22:19
Show Gist options
  • Save nofilenamed/6a60f9ad4a264c8bf39c to your computer and use it in GitHub Desktop.
Save nofilenamed/6a60f9ad4a264c8bf39c to your computer and use it in GitHub Desktop.
Make SVG clickable in a-tag and with image fallback
/**
* 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