Last active
April 6, 2022 11:12
-
-
Save BroFox86/29420e64d9424247d929284b2ee29187 to your computer and use it in GitHub Desktop.
[Responsive background] #responsive CSS background image via media queries
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
// | |
// Responsive background image via media queries. More info here: | |
// developers.google.com/web/fundamentals/design-and-ux/responsive/images | |
// | |
.block { | |
// Mobile standard image. | |
background-image: url("../images/mobile.png"); | |
background-repeat: no-repeat; | |
background-size: contain; | |
// Mobile high resolution image. | |
@media (min-resolution: 2dppx), (-webkit-min-device-pixel-ratio: 2) { | |
background-image: url("../images/mobile@2x.png"); | |
} | |
// Desktop standard image. | |
@media (min-width: $large-screen) { | |
background-image: url("../images/desktop.png"); | |
} | |
// Desktop high resolution image. | |
@media (min-width: $large-screen) and (min-resolution: 2dppx), | |
(min-width: $large-screen) and (-webkit-min-device-pixel-ratio: 2) { | |
background-image: url("../images/desktop@2x.png"); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment