Skip to content

Instantly share code, notes, and snippets.

@joliveras
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joliveras/b8f4c1ea9db531bfa635 to your computer and use it in GitHub Desktop.
Save joliveras/b8f4c1ea9db531bfa635 to your computer and use it in GitHub Desktop.
.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");
}
}
$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.
$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