Skip to content

Instantly share code, notes, and snippets.

@koycarraway
Created July 12, 2013 02:57
Show Gist options
  • Save koycarraway/5981075 to your computer and use it in GitHub Desktop.
Save koycarraway/5981075 to your computer and use it in GitHub Desktop.
Sass Mixin for background-size: cover property. Includes IE support.
// $bg-img-path: '../path/to/image.jpg'
// $bg-options: options are css background properties (ex. no-repeat center center)
@mixin bg-cover($bg-img-path, $bg-options) {
background: url($bg-img-path) $bg-options;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='#{$bg-img-path}', sizingMethod='scale');
-ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='#{$bg-img-path}', sizingMethod='scale')";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment