Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Condense stylesheet size by using the average width and height of the sprites #37

Open
ghost opened this issue Apr 11, 2015 · 0 comments

Comments

@ghost
Copy link

ghost commented Apr 11, 2015

Stitches successfully generated this sprite sheet:

Almost all flags are 16x11 in size, but two of them are 11x11, so the stylesheet looks like this:

.flags {
    background-image: url(spritesheet.png);
    background-repeat: no-repeat;
    display: block;
}

.flags-ad {
    width: 16px;
    height: 11px;
    background-position: 0 0;
}

/* ... */

.flags-ch {
    width: 11px;
    height: 11px;
    background-position: -192px 0;
}

The approach is simple: .flags would be 16x11 in size, and the width and height properties would be omitted in every sprite unless its size differs from the average, something like this:

.flags {
    width: 16px;
    height: 11px;
    background-image: url(spritesheet.png);
    background-repeat: no-repeat;
    display: block;
}

.flags-ad {
    background-position: 0 0;
}

/* ... */

.flags-ch {
    width: 11px;
    background-position: -192px 0;
}

Apart from that, Stitches is a great and useful tool, nice job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants