Skip to content

Instantly share code, notes, and snippets.

@theaccordance
Last active December 17, 2015 00:38
Show Gist options
  • Select an option

  • Save theaccordance/5522049 to your computer and use it in GitHub Desktop.

Select an option

Save theaccordance/5522049 to your computer and use it in GitHub Desktop.
Method for providing higher quality images for Retina/4k enabled screens, using a Media Query to load the conditional values when screens match the specified criteria. Since retina graphics are twice the width and height of the original graphic, the rule set for retina graphics should also include an additional property (background-size) to tell…
/* Background Image Property for Normal Screens */
.ui-icon-menu {
background: url('../img/icon-menu.png') center center no-repeat;
}
/* Background Image Property for Retina Screens */
@media only screen and (-webkit-min-device-pixel-ratio : 1.5), only screen and (min-device-pixel-ratio : 1.5) {
/* Best Practice: Indent Rulesets within Media Queries */
.ui-icon-menu {
background: url('../img/icon-menu@2x.png') no-repeat;
background-size: 24px 24px;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment