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

CSS CSS Basics (2014) Basic Layout Backgrounds: Size and Position

Aakash Srivastav
seal-mask
.a{fill-rule:evenodd;}techdegree
Aakash Srivastav
Full Stack JavaScript Techdegree Student 11,638 Points

background-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
Patrik Horváth
11,110 Points

old theme : https://teamtreehouse.com/community/explain-the-difference-between-the-100-value-in-backgroundsize-property-and-cover-value

and 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