Skip to content

Instantly share code, notes, and snippets.

@polikin
Created October 31, 2013 15:07
Show Gist options
  • Save polikin/7251313 to your computer and use it in GitHub Desktop.
Save polikin/7251313 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.1)
// Compass (v0.13.alpha.10)
// ----
@mixin backgroundimage($name, $ext, $pos:top left, $repeat: no-repeat, $bgcolor:transparent, $bgsize: null, $important:null, $size: null, $height: null, $fallback:null) {
background: image-url('#{$name}.#{$ext}') $pos $repeat $bgcolor $important;
@if $ext == svg {
@if $fallback == false {
//no png fallback
}@else {
.no-svg & { background: image-url('#{$name}.png') $pos $repeat $bgcolor $important; }
}
}
@if $bgsize != null {
background-size: $bgsize;
}
@if $size == true {
@if $ext == svg {
height: image-height('#{$name}.png');
width: image-width('#{$name}.png');
}
@else {
height: image-height('#{$name}.#{$ext}');
width: image-width('#{$name}.#{$ext}');
}
}
@if $height == true {
height: image-height('#{$name}.#{$ext}');
@if $ext == svg {
height: image-height('#{$name}.png');
}
}
}
.background-image {
@include backgroundimage(my-image, svg);
}
/*******/
.background-image-svg-fallback-false {
@include backgroundimage(my-image, svg, $fallback:false);
}
.background-image {
background: url('/my-image.svg') top left no-repeat transparent;
}
.no-svg .background-image {
background: url('/my-image.png') top left no-repeat transparent;
}
/*******/
.background-image-svg-fallback-false {
background: url('/my-image.svg') top left no-repeat transparent;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment