Generating Spritesheets

If you are not familiar with spritesheets, please read this article first http://www.w3schools.com/css/css_image_sprites.asp.


How it Works

RebelMouse provides you with tools to create spritesheet files automatically using your individual icons. The tool will create spritesheet files in both retina and non-retina formats, as well as their respective CSS markup.

To generate spritesheets for your projects use

roar-generate_sprites

The image folder is located in static/img/whitelabel/. All images should be located here.

A spritesheet is created for each group of files under each folder of the sprites folder.

Take as an example this set of folders:

static/img/whitelabel/sprites/logos/
static/img/whitelabel/sprites/ui/

2 spritesheet files will be created for folders ui and logos automatically by using the roar-generate_sprites command.

Spritesheets will be located here:

static/img/whitelabel/spritesheets/logos@2x.png
static/img/whitelabel/spritesheets/logos.png
static/img/whitelabel/spritesheets/ui@2x.png
static/img/whitelabel/spritesheets/ui.png

Stylesheets will be located here:

static/css/roar/spritesheets/logos.css
static/css/roar/spritesheets/ui.css

Step by Step

Create a folder called sprites, under static/img/whitelabel/, if it's not already created.

Create a folder for each new spritesheet you need, under sprites folder.

Put all the .png files you need into created folder. Note: images should be retina size, meaning 2x of their normal size.

Run the command roar-generate_sprites.

Import the generated CSS into your project's critical.css file, if it is not there yet.


Using the Spritesheets

Beside the spritesheet .png file, a .css file is generated as well. It contains CSS classes for all images which also handle retina displays which means you don't have to worry about high quality displays. Simply add the class to the element you want the image to show in.

For example, if your image file is located:

static/img/whitelabel/sprites/ui/yourfile.png

Then the class will be:

.sprites-ui-yourfile
Reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
Like1 Follow
  • 1 Likes
  • 2 yrs agoLast active
  • 513Views
  • 1 Following