Skip to content

Instantly share code, notes, and snippets.

@dtbaker
Created October 30, 2014 08:27
Show Gist options
  • Select an option

  • Save dtbaker/abfe70034aa9f4e993a6 to your computer and use it in GitHub Desktop.

Select an option

Save dtbaker/abfe70034aa9f4e993a6 to your computer and use it in GitHub Desktop.
simple less mixin
@highdpi: ~"((-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx))";
.double_background(@url){
background: ~"@{url}";
@media @highdpi {
background: ~`@{url}.replace(/images\//g, 'images/2x/')`;
}
}
#your_element{
.double_background('#f3dbab url(images/icon-cart.png)');
background-repeat: no-repeat;
background-size: 12px 10px;
background-position: right;
background-origin: padding-box;
}
/*** it outputs the below CSS: ***/
#your_element {
background: #f3dbab url(images/icon-cart.png);
background-repeat: no-repeat;
background-size: 12px 10px;
background-position: right;
background-origin: padding-box;
}
@media ((-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)) {
#your_element {
background: #f3dbab url(images/2x/icon-cart.png);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment