Skip to content

Instantly share code, notes, and snippets.

@bluehazetech
Created March 25, 2014 12:27
Show Gist options
  • Save bluehazetech/9760852 to your computer and use it in GitHub Desktop.
Save bluehazetech/9760852 to your computer and use it in GitHub Desktop.
CSS: SVG Images
<!-- 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