Created
January 27, 2019 11:26
-
-
Save djpogo/9671e2132ef7e6c41980082a4931415a to your computer and use it in GitHub Desktop.
scss background-image: url() mixin
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 bg-url($url, $url2x: false, $webp1x: false, $webp2x: false) { | |
background-image: url($url); | |
@if $webp1x { | |
.webp & { | |
background-image: url($webp1x); | |
} | |
} | |
@if $url2x { | |
@media | |
screen and (-webkit-min-device-pixel-ratio: 2), | |
screen and (min-resolution: 192dpi), | |
screen and (min-resolution: 2dppx) { | |
background-image: url($url2x); | |
@if $webp2x { | |
.webp & { | |
background-image: url($webp2x); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment