Created
July 28, 2017 16:44
-
-
Save ktusznio/cb0b80bf6c08d328cd5ec43e41cd03d5 to your computer and use it in GitHub Desktop.
Responsive SASS mixins for retina displays
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
.hero { | |
background: url('/images/hero-mobile.jpg') no-repeat center center; | |
background-size: cover; | |
@include breakpoint(tablet) { | |
background-image: url('/images/hero.jpg'); | |
} | |
@include retina { | |
background-image: url('/images/[email protected]'); | |
@include breakpoint(tablet) { | |
background-image: url('/images/[email protected]'); | |
} | |
} | |
} |
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
@mixin breakpoint($media) { | |
@if $media == tablet { | |
@media only screen and (min-width: $screen-md-min) { @content; } | |
} @else if $media == desktop { | |
@media only screen and (min-width: $screen-lg-min) { @content; } | |
} | |
} | |
@mixin retina { | |
@media only screen and (min--moz-device-pixel-ratio: 2), | |
only screen and (-o-min-device-pixel-ratio: 2/1), | |
only screen and (-webkit-min-device-pixel-ratio: 2), | |
only screen and (min-device-pixel-ratio: 2) { | |
@content; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment