Note that there are some explanatory texts on larger screens.

plurals
  1. POSprite loading multiple times, not caching as I would expect
    primarykey
    data
    text
    <p>I am trying to create a sprite mixin, based on the <a href="http://compass-style.org/reference/compass/utilities/sprites/sprite_img/" rel="nofollow noreferrer">compass sprite mixins for SCSS</a>.</p> <p>The trouble is that the image is loading multiple times. One for each unique call of the image (so each new class name that refers to the sprite)</p> <p>Here is the SCSS I am using. First we call the compass mixins:</p> <pre><code>$sprite-default-size:29px; @import "compass/utilities/sprites/sprite-img"; </code></pre> <p>Then I create my own mixin, designed to accept a column of images, with hover states to the right of each image:</p> <pre><code>$icons: "/assets/icons/socialMediaSprite.png"; @mixin verticalHoverSprite($row){ @include sprite-img("/assets/icons/socialMediaSprite.png",1,$row); &amp;:hover{ @include sprite-img($icons,2, $row); } } </code></pre> <p>The I use the apply the mixins to each required class:</p> <pre><code> .socialMediaLink{ @include verticalHoverSprite(1); &amp;.facebook{ @include verticalHoverSprite(2); } &amp;.twitter{ @include verticalHoverSprite(3); } } </code></pre> <p>Here is the HTML I am attaching the images to:</p> <pre><code>&lt;span class="socialMediaLink"&gt;&lt;/span&gt; &lt;span class="facebook socialMediaLink"&gt;&lt;/span&gt; &lt;span class="twitter socialMediaLink"&gt;&lt;/span&gt; </code></pre> <hr> <p>Screen shot from Chrome network panel, which shows the image loading three times:</p> <p><img src="https://i.stack.imgur.com/fzMyy.png" alt="Screen shot from Chrome network panel"></p>
    singulars
    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