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

Medua Okonta
Medua Okonta
8,808 Points

Responsive background image

Is there a way I can make a background image responsive? I've tried a number of ways but haven't found a solution.

Is it possible in css or query?

4 Answers

Guil Hernandez
STAFF
Guil Hernandez
Treehouse Teacher

Medua Okonta,

Check out this Quick Tip I did on full page background images. I also cover it in the CSS Deep Dive on background properties.

Chase Lee
Chase Lee
29,275 Points

You can do it in CSS by using a percentage value for the width and height, like this:

img{
    width: 35%;
    height: 20%;
}

Hope that helps.

Medua Okonta
Medua Okonta
8,808 Points

Thanks for the tips guys!