Have you tried this compass snippet?
$icons: sprite-map("icons/*.png"); i{ background: $icons; display: inline-block; // or block } @each $i in sprite_names($icons){ .icn-
This example uses <i></i> -tag with a class containing the icn- prefix in combination with the file name of the individual .png files in the icons folder. Like this:
<i class="icn-delete"></i>
The generated CSS looks like this:
i { background: url('/path/to/generated/spritemap/my-icons-xxxxxxxxxxx.png'); display: inline-block; } .icn-delete { background-position: 0 0; height: 32px; // assuming the width is 32px width: 32px; // assuming the height is 32px } .icn-edit{ background-position: 0 -32px; height: 32px; // assuming the width is 32px width: 32px; // assuming the height is 32px } .icn-new { background-position: 0 -64px; height: 32px; // assuming the width is 32px width: 32px; // assuming the height is 32px } ... .. .
However, I did not quite understand how to use this in conjunction with the compass Magic Selectors .
Magic Selectors works very well when you need different states (: hover ,: active ,: target). All you have to do is name your files as follows: filename_state.png (delete_hover.png, delete_active.png, etc.). Then, "Compass Magic Selectors" automatically generate css for: hover ,: active and: target (delete: hover, delete_hover and delete-hover). This way you can freely choose how you will represent the state change.
If in the first example you have postfix file names for freezes / active states, the fragment only writes CSS as follows:
.icn-edit_hover { background-position: -32px -32px; height: 32px; width: 32px; }
I would really like this to print this:
.icn-edit:hover, .icn-edit_hover, .icn-edit-hover{ background-position: 0 -32px; height: 32px; width: 32px; }
like the traditional Magic Selectors compass . Any idea?
user1136396
source share