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

Istanus Mutashobya
Istanus Mutashobya
4,378 Points

Hey guys I have been doing some exercises in my frontend track. I need help in making images scalable with screen size.

What CSS attributes are suitable for responsiveness of images. Can you use percentage in sizing images

1 Answer

Hello

Check out this site concerning responsive web images.

Scale both up and down

.responsive {
    width: 100%;
    height: auto;
}

scale down if it has too but never up or larger than max size

.responsive {
    max-width: 100%;
    height: auto;
}

if you want to restrict the size that the image can scale too

.responsive {
    width: 100%;
    max-width: 400px;
    height: auto;
}

Hope this helps.

Istanus Mutashobya
Istanus Mutashobya
4,378 Points

Hello Daniel, Thanks for your time and answering in such short notice. Your answer was helpful have tried it in my code and works great, Thanks.