Last active
December 16, 2015 21:20
-
-
Save chadclark/5498661 to your computer and use it in GitHub Desktop.
A .scss mixin that makes it easy to include a .png fallback for .svg background images when using Modernizr.
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
// --------------------------------------------------------------------------------- | |
// CSS Image Paths | |
// --------------------------------------------------------------------------------- | |
$bg-img-path: '/path/to/images/'; // Base Path for BG Layout Images |
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
// --------------------------------------------------------------------------------- | |
// Modernizr SVG Fallback | |
// Inspired by https://forrst.com/posts/Sass_Compass_Mixin_for_SVG_Background_Image_Fall-dWn | |
// --------------------------------------------------------------------------------- | |
@mixin no-svg { .no-svg & { @content } } | |
@mixin svg-bkgd($filename, $pos-x: '0', $pos-y: '0', $repeat: 'no-repeat', $extension: '.png') { | |
background: transparent url($bg-img-path + $filename + '.svg') $pos-x $pos-y $repeat; | |
@include no-svg { background: transparent url($bg-img-path + $filename + $extension) $pos-x $pos-y $repeat; } | |
} |
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
// --------------------------------------------------------------------------------- | |
// How to Use | |
// --------------------------------------------------------------------------------- | |
@include svg-bkgd(filename, right, center, no-repeat); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment