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 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%;
}