Search code examples
backgroundcssbackground-position

Placing an image from the sprite in the specific position


Let's say i have a sprite with lots of icons. I want to place one of the icons in the specific position over the div, e.g. 15px from the right side and 20px from the top. Previously, when i had single image file i used the following code:

background: white url(./imgs/some/icon.png) no-repeat 91% 47%;

Now then the image is in the sprite i can access it using

background-position: 0 -471px;

But as i see it there is no place to add my current 91% 47%. Is there some kind of workaround? It's possible to use CSS3 in the project if it helps.

Thanks!


Solution

  • Would you be able to add another <div>, give it the correct background, and absolute position it where it needs to be? I'm thinking that your background-position percentages are probably out when you use a sprite sheet.