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 trialAakash Srivastav
Full Stack JavaScript Techdegree Student 11,638 Pointsbackground-size
Whats the difference between - background-size: 100% 100%; and background-size: cover; Please explain . I read articles and also took help of w3c , but didn't found any result.
1 Answer
Patrik Horváth
11,110 Pointsand my answere stay same :
background-size:100%;
is same as
background-size:100% auto;
= the width is set to be 100% large and the height of the background image follows respecting the image aspect ratio.
background-size:cover;
means the background image will always fit the whole div , you won't be left with any empty spots in your div
background-size:100% 100%;
won't leave any empty space too, but of course this will destroy the original image aspect ratio