Ketri Ketri - 6 months ago 22
CSS Question

Is there a CSS sprite generator that also gives retina -versions?

If there already isn't one, I would very much appreciate if someone could give some instructions on how to make a retina and non-retina CSS-sprite myself. Preferably using some CSS sprite -generator in the process if possible.

Related to topic:

Thank you all in advance!


Method 1

Here's a Mixin to achieve this with Compass

Method 2

  1. Create two version of your image files, one for "regular" density screens, the other for retina screens, with pictures twice the resolution. (Meaning if one of the pictures is 23px by 41 px, the retina version would be 46px by 28 px)
  2. Go to and create two versions of your sprite image. Lets assume your images have a smaller dimension than 25px. Choose Horizontal Offset: 25px in the first non-retina version, and 50px in the retina version. Save your sprites as sprite.png and spritex2.png
  3. In your css file you can now define something along the rough lines of:

         background-image: url(sprite.png);
    @media only screen and (-webkit-min-device-pixel-ratio: 1.5),
    only screen and (min--moz-device-pixel-ratio: 1.5),
    only screen and (min-resolution: 240dpi) {
         background-image: url(spriteX2.png);
    .spriteA{ background-position: 0 50%; }
    .spriteB{ background-position: -31px 50%; }

This way, the background position ratio (50%) is maintained whether you using the non-retina or retina resolutions.