Last active
August 29, 2015 14:02
-
-
Save joliveras/b8f4c1ea9db531bfa635 to your computer and use it in GitHub Desktop.
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
.svg-background-image (@filename:@filename){ | |
background-repeat: no-repeat; | |
.svg &{ | |
background-image: url("@{i-folder}@{filename}.svg"); | |
} | |
.no-svg &{ | |
background-image: url("@{i-folder}@{filename}.png"); | |
} | |
} |
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
$svg-path: "img/svg/"; | |
$png-path: "img/png/"; | |
@mixin svg-background-image ($name, $link){ | |
.svg &{ | |
background-image: url(#{$svg-path}#{$name}.svg); | |
@if $link == true{ | |
&:hover{ | |
background-image: url(#{$svg-path}#{$name}-hover.svg); | |
} | |
} | |
} | |
.no-svg &{ | |
background-image: url(#{$png-path}#{$name}.png); | |
@if $link == true{ | |
&:hover{ | |
background-image: url(#{$png-path}#{$name}-hover.png); | |
} | |
} | |
} | |
} | |
// Use: @include svg-background-image('image-name', true); | |
// True if :hover img exists. |
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
$path: "img/icons/"; | |
@mixin svg-background-image ($name, $link){ | |
.svg &{ | |
background-image: url(#{$path}#{$name}.svg); | |
@if $link == true{ | |
&:hover{ | |
background-image: url(#{$path}#{$name}-hover.svg); | |
} | |
} | |
} | |
.no-svg &{ | |
background-image: url(#{$path}#{$name}.png); | |
@if $link == true{ | |
&:hover{ | |
background-image: url(#{$path}#{$name}-hover.png); | |
} | |
} | |
} | |
} | |
// Use: @include svg-background-image('image-name', true); | |
// True if :hover img exists. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment