Skip to content

Instantly share code, notes, and snippets.

@zmmbreeze
Last active December 20, 2015 01:19
Show Gist options
  • Select an option

  • Save zmmbreeze/6048684 to your computer and use it in GitHub Desktop.

Select an option

Save zmmbreeze/6048684 to your computer and use it in GitHub Desktop.
hidpi.less
// from https://github.com/neoziro/less-hidpi/blob/master/hidpi.less
// Configuration
@hidpi_min_ratio: 1.5;
@hidpi_suffix: "@2x";
// Mixin
@hidpi_query: ~"(-webkit-min-device-pixel-ratio: @{hidpi_min_ratio}), (min--moz-device-pixel-ratio: @{hidpi_min_ratio}), (-o-min-device-pixel-ratio: @{hidpi_min_ratio}), (min-resolution: @{hidpi_min_ratio}dppx)";
.hidpi(@path, @w: auto, @h: auto) {
background-image: url(@path);
@at2x_path: ~`@{path}.replace(/\.\w+$/, function(match) { return @{hidpi_suffix} + match; })`;
@media @hidpi_query {
background-image: url("@{at2x_path}");
background-size: @w @h;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment