Skip to content

Instantly share code, notes, and snippets.

@corysimmons
Created March 11, 2015 13:15
Show Gist options
  • Save corysimmons/69d3c6642e035fefbe98 to your computer and use it in GitHub Desktop.
Save corysimmons/69d3c6642e035fefbe98 to your computer and use it in GitHub Desktop.
Stylus Retina Mixin
retina(file, ext)
background-image: url(file'.'ext)
@media (-webkit-min-device-pixel-ratio: 2),
( min--moz-device-pixel-ratio: 2),
( -o-min-device-pixel-ratio: 2/1),
( min-device-pixel-ratio: 2),
( min-resolution: 192dpi),
( min-resolution: 2dppx)
background-image: url(file'@2x.'ext)
background-size: cover
Copy link

ghost commented May 21, 2015

background-size: cover might not always work for what you need, might want to add width/height params

@Nikodermus
Copy link

Hello Mate! I love that you think the same way as I do with stylus.
That's the right mixin I was looking for.
In order to use it it would something like
.item retina(mybackground, jpg)
Sorry for the dumb question!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment