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) Enhancing the Design With CSS Media Query Basics

working Media Queries, and everything resizes correctly when the viewport changes but the picture stays the same. Help!

I am working on an ebay post and I am using media queries. I specified two viewport sizes (max-width) at 700px and other at 480px. The text resizes well to the size I specified but the picture stays the same size. How can I make it to display correctly at 700px and 480px ?

What does your HTML and CSS look like? Without seeing the actual code, it's hard to know what's going on. When I write a simple media query, it works fine for manipulating an image.

@media screen and (max-width: 480px) {
  img { width: 480px }
}

@media screen and (min-width: 481px) and (max-width: 700px) {
  img { width: 700px }
}
Harry Beckwith
Harry Beckwith
13,452 Points

Does the image have a set width on it?

Also try setting in CSS

img { max-width:100%; }

This will ensure the image will be no larger than its container.

1 Answer

Sina Maleki
Sina Maleki
6,135 Points

Hi You have to set the max-width of your img selector to 100%

img {
   max-width: 100%;
}