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 trialSean Flanagan
33,235 PointsBackground-size
If the width and height of background-size are the same, doesn't it make sense to type:
background-size: 18px;
2 Answers
Steven Parker
231,198 PointsIt does seem like it might make sense, but that's not the way it works.
The first value sets the width, the second value sets the height. If only one value is given, the second is set to "auto". So by default, the height is set so that it preserves the aspect ratio of the image.
So to constrain both the height and width, provide the value twice:
background-size: 18px 18px;
Sean Flanagan
33,235 PointsI understand. Thanks for your help. I've upvoted your reply and given you Best Answer.
Thank you
Sean :-)