Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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!