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

Stefan Pupcevic
Stefan Pupcevic
1,306 Points

Can we just use background-size: 100%; for background image size?

Can we just use that function instead of messing with repeat? I used it and it looks good and stretched!

Hi, try apply applying the following:

Background-size: Cover; Background-position: Center;

This might give you desired results

1 Answer

Steven Parker
Steven Parker
231,248 Points

There are a variety of background size settings, as you discovered you can stretch it to fit, and two popular settings that do not affect aspect ratio are "contain" and "cover".

For more details on these and other settings, see the MDN page on background-size.