Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Mark Miller
16,375 PointsFade between 'background-position' of a sprite image using css3 animations
I'm working with an image sprite containing icons (original and hovered states).
My goal is to animate an .li original 'background-position' so when hovered the image would fade into another image.
li{ width: 28px; height: 28px; background-repeat: no-repeat; background-image: url(../img/icons.png); background-position: -1px -3px; }
li:hover { animation: spritehover .1s forwards; }
@keyframes spritehover { 100% { background-position: -1px -31px; } }
The above code only shifts the background position of the image sprite. I want to fade the between the two background positions.
Any suggestions on how I can fade between the sprite's two background positions?