chaonextdoor
chaonextdoor

Reputation: 5129

How to specify the position in both CSS sprite and element's background

I want to show part of a sprite image positioned at X and Y at the upper right corner of a div element. How should I do? For example, if I usebackground: url("the path") no-repeat 0 0 it will show the whole sprite image at the upper right corner of the div element. So actually I need to specify two coordinates, one is in sprite image, the other is in the div element.

Upvotes: 0

Views: 83

Answers (1)

AddiktedDesign
AddiktedDesign

Reputation: 512

you have to wrap the sprite in another container and give that a specified height an width which is that of the section of the sprite you want to see, and then position the sprite in that.

like this: http://jsfiddle.net/Qa8Tp/

Upvotes: 1

Related Questions