Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to create a sprite from a folder with and without background-size (using Compass)
    primarykey
    data
    text
    <p>I want to use a Compass generated icon-sprite for two different scenarios.</p> <ol> <li>Use the icon(s) in original size.</li> <li>Use it the same icon(s) as a smaller version using CSS3 property <code>background-size</code>.</li> </ol> <p>I first do this:</p> <pre><code>$logo-spacing: 20px; @import "logo/*.png"; @include all-logo-sprites; </code></pre> <p>Now I can use the general created CSS-classes like <code>.logo-twitter</code> etc.</p> <p>Two achieve the second result I could use this (<a href="https://gist.github.com/3410875">darren131 / gist:3410875 - resize sprites in Compass</a>):</p> <pre><code>@mixin resize-sprite($map, $sprite, $percent) { $spritePath: sprite-path($map); $spriteWidth: image-width($spritePath); $spriteHeight: image-height($spritePath); $width: image-width(sprite-file($map, $sprite)); $height: image-height(sprite-file($map, $sprite)); @include background-size(ceil($spriteWidth * ($percent/100)) ceil($spriteHeight * ($percent/100))); width: ceil($width*($percent/100)); height: ceil($height*($percent/100)); background-position: 0 floor(nth(sprite-position($map, $sprite), 2) * ($percent/100) ); } .my-other-div-with-small-logos { .logo-twitter { $spriteName: twitter; $percentage: 40; @include resize-sprite($logo-sprites, $spriteName, $percentage); } } </code></pre> <p>But if I have around 30 logos I would need to repeat this manually for each sprite-class.</p> <p>Is it possible to import the folder twice, once for the original size and a second time with the <code>backround-size</code> property? Or modify the mentioned method to create all classes automatically within another <code>&lt;div class="my-other-div-with-small-logos"&gt;</code> where the icons should appear smaller?</p> <p>Or am I thinking in the wrong direction here?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload