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 trialgeoffrey
28,736 PointsSetting multiple background images with :before ? Is there any reason ?
Hey Guil Hernandez , I 've lately watched the framework basic course and the ribbit project. In this one, you use sprite sheet images to set the multiple background-image.
However, instead of using multiple background images in a css rule. You instead use the :before pseudo class. Is there any good reason of doing it ? It's not that much a problem, but I was just wondering if there is a good reason to do that this way...
For more clarity, I created this pen to show what you did and what I would have done on my side...
Thank you, here is the pen
2 Answers
Guil Hernandez
Treehouse TeacherIf I'm using single images as the icons, sure, multiple backgrounds might be more efficient. With sprite sheets, it can get a little bit trickier because of how compact they areβsome of the other icons may show, and you'll have to consider the space around each sprite.
So, I prefer the commonly used pseudo-element approach. Neither method is 100% right or wrong β use what works best for you. :)
AR Ehsan
7,912 PointsI think there is. Not sure!
geoffrey
28,736 Pointsgeoffrey
28,736 PointsThank you for your answer Guil, that's just I wanted to be 100% sure of that, and now this is the case ;)