Skip to content

Instantly share code, notes, and snippets.

@iign
Created March 17, 2015 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iign/d5ed575dc773286ae0ad to your computer and use it in GitHub Desktop.
Save iign/d5ed575dc773286ae0ad to your computer and use it in GitHub Desktop.
3x support for retina.less mixin
.at2x(@path, @w: auto, @h: auto) {
background-image: url(@path);
@at2x_path: ~`@{path}.replace(/\.\w+$/, function(match) { return "@2x" + match; })`;
@at3x_path: ~`@{path}.replace(/\.\w+$/, function(match) { return "@3x" + match; })`;
@media @highdpi {
background-image: url("@{at2x_path}");
background-size: @w @h;
}
@media @3xdpi {
background-image: url("@{at3x_path}");
background-size: @w @h;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment