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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mardash
    New Member
    • Mar 2012
    • 10

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

    Code:
    .sprite{
    background:url(Sprite.png)
    }
    .feed{
    background-position: -76px 0px;
    }
    easy i can add sprite to div images like that ...

    Code:
    <DIV STYLE='position:absolute; right:970px; top:2px;'>
    <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

    Code:
    .sky{
    background-position: -76px 0px;
    }
    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

    Code:
    body{
    background:#8C1616 url(sky.jpeg)
    }
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    Code:
    .sprite{
    background:url(Sprite.png)
    }
    .feed{
    background-position: -76px 0px;
    }
    easy i can add sprite to div images like that ...

    Code:
    <DIV STYLE='position:absolute; right:970px; top:2px;'>
    <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?)

    Comment

    • mardash
      New Member
      • Mar 2012
      • 10

      #3
      so i can't use sprite with image in css ?

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        you’re not supposed to use sprites with <img> elements.

        Comment

        Working...