By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,341 Members | 1,681 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,341 IT Pros & Developers. It's quick & easy.

how to add sprite class to image in "css" not in "div"?

mardash
P: 10
Expand|Select|Wrap|Line Numbers
  1. .sprite{
  2. background:url(Sprite.png)
  3. }
  4. .feed{
  5. background-position: -76px 0px;
  6. }
easy i can add sprite to div images like that ...

Expand|Select|Wrap|Line Numbers
  1. <DIV STYLE='position:absolute; right:970px; top:2px;'>
  2. <a href='../feed'><img class='sprite feed' height='32' src='transpernt.png' width='32'/></a></DIV>
now it's ok :)

but i asked if i have image in css not in div like ..

i can make

Expand|Select|Wrap|Line Numbers
  1. .sky{
  2. background-position: -76px 0px;
  3. }
Easy to make sky class .. but the hard thing is
how i replace this skyimage with sprite .. or how i add the class="sprite sky" to it ?
i no see div to add class :(

this's example

Expand|Select|Wrap|Line Numbers
  1. body{
  2. background:#8C1616 url(sky.jpeg)
  3. }
Apr 16 '12 #1
Share this Question
Share on Google+
3 Replies


Dormilich
Expert Mod 5K+
P: 8,639
Expand|Select|Wrap|Line Numbers
  1. .sprite{
  2. background:url(Sprite.png)
  3. }
  4. .feed{
  5. background-position: -76px 0px;
  6. }
easy i can add sprite to div images like that ...

Expand|Select|Wrap|Line Numbers
  1. <DIV STYLE='position:absolute; right:970px; top:2px;'>
  2. <a href='../feed'><img class='sprite feed' height='32' src='transpernt.png' width='32'/></a></DIV>
now it's ok :)
no, it’s not. <img> elements are not supposed to have a background. (you don’t put a transparent poster on the wall to look at the tapestry either, do you?)
Apr 16 '12 #2

mardash
P: 10
so i can't use sprite with image in css ?
Apr 16 '12 #3

Dormilich
Expert Mod 5K+
P: 8,639
you’re not supposed to use sprites with <img> elements.
Apr 16 '12 #4

Post your reply

Sign in to post your reply or Sign up for a free account.