Skip to content

Instantly share code, notes, and snippets.

@kovtunos
Last active July 23, 2016 17:23
Show Gist options
  • Save kovtunos/d44d26a58305595fe0a78d3faf4f94dc to your computer and use it in GitHub Desktop.
Save kovtunos/d44d26a58305595fe0a78d3faf4f94dc to your computer and use it in GitHub Desktop.
Full width banner #mixin
// Full width image banner.
//
// Usage:
// @include banner('../images/banner.jpg')
// @include banner('../images/banner.jpg', 700px)
// @include banner('../images/banner.jpg', 700px, center, center, #fff)
// @include banner('../images/banner.jpg', 700px, center, center, #fff, true)
// @include banner('../images/banner.jpg', 700px, center, center, #fff, false, rgba(255, 0, 0, .45))
@mixin banner($url, $height: 600px, $horizontal: center, $vertical: center, $fallback-color: null, $paralax: null, $overlay: null) {
@if($overlay) {
background: linear-gradient($overlay, $overlay), url($url);
} @else {
background-image: url($url);
}
background-position: $horizontal $vertical;
background-size: cover;
@if($fallback-color) {
background-color: $fallback-color;
}
@if($paralax) {
background-attachment: fixed;
background-repeat: repeat-x;
}
min-height: $height;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment