Last active
October 5, 2015 22:08
-
-
Save cacheflowe/2885138 to your computer and use it in GitHub Desktop.
Media queries to load only 1 image per browser width / pixel density
This file contains hidden or 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
// webkit-only .sass -------------------------------- | |
@media (min-width: 20px) and (max-width: 480px) and (-webkit-min-device-pixel-ratio: 1.5) | |
#site-loader-inner | |
background: transparent url('mobile/loaders/[email protected]', image) | |
@media (min-width: 20px) and (max-width: 480px) and (-webkit-max-device-pixel-ratio: 1.5) | |
#site-loader-inner | |
background: transparent url('mobile/loaders/loader-spin.png', image) | |
// retina-respond.scss mixin ------------------------------- | |
@mixin respond-to($media) { | |
@if $media == nonretina { | |
@media (-webkit-max-device-pixel-ratio: 1.5), (max-resolution: 143dpi) { @content; } | |
} | |
@else if $media == retina { | |
@media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) { @content; } | |
} | |
} | |
// example use: | |
@include respond-to(nonretina) | |
background: $white-bg url($file-fire) center top no-repeat | |
@include respond-to(retina) | |
background: $white-bg url($file-fire-2x) center top no-repeat | |
background-size: 311px 208px |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment