Created
March 25, 2014 12:27
-
-
Save bluehazetech/9760852 to your computer and use it in GitHub Desktop.
CSS: SVG Images
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
<!-- inline SVG with inline fallback --> | |
<object data="image.svg" type="image/svg+xml"> | |
<img src="image.png" /> | |
</object> | |
<!-- inline SVG with CSS fallback using Modernizr --> | |
<object data="image.svg" type="image/svg+xml" class="svg"> | |
SVG Image <!-- CSS fallback image --> | |
</object> | |
.no-svg .svg { | |
background-image: url(image.png); | |
width: 100px; | |
height: 100px; | |
} | |
<!-- CSS SVG with CSS fallback --> | |
.svg { | |
background: url(fallback.png); | |
background-image: url(image.svg), none; | |
} | |
<!-- CSS SVG with CSS fallback using Modernizr --> | |
.svg { | |
background: url(image.svg) no-repeat; | |
background-size: contain; | |
} | |
.no-svg .svg { | |
background-image: url(image.png); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment