Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Sprite - is there a possible short way?

Tags:

html

css

E.g. I hava a 3 diffrent image as a sprite with hover.

e.g. for sprite

<div class="sprite normal"></div>

i dont want this type!

/* small */
    .small{ width:20px; height:20px; }
    .small .sprite{ background:url(sprite.png) 0 0 no-repeat; }
    .small .sprite:hover { background:url(sprite.png) 20px 0 no-repeat; }
/* normal*/
    .normal{ width:50px; height:50px; }
    .normal .sprite{ background:url(sprite.png) 0 0 no-repeat; }
    .normal .sprite:hover { background:url(sprite.png) 50px 0 no-repeat; }
/* big */
    .big{ width:100px; height:100px; }
    .big .sprite{ background:url(sprite.png) 0 0 no-repeat; }
    .big .sprite:hover { background:url(sprite.png) 100px 0 no-repeat; }

is there a short way? thank you..

like image 771
avalkab Avatar asked Dec 05 '25 10:12

avalkab


1 Answers

.sprite{ background:url(sprite.png) 0 0 no-repeat; }

/* small */
    .small{ width:20px; height:20px; }
    .small .sprite:hover { background:url(sprite.png) 20px 0 no-repeat; }

/* normal*/
    .normal{ width:50px; height:50px; }
    .normal .sprite:hover { background:url(sprite.png) 50px 0 no-repeat; }

/* big */
    .big{ width:100px; height:100px; }
    .big .sprite:hover { background:url(sprite.png) 100px 0 no-repeat; }

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!