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

How can I resize my images in css?

Hi there, So I have 6 images on the home page of my website, 5 are completely exact, 760 and 620, but the last image just won't quite fit, so I resize the 6th image to 760 and 620. Now it fits absolutely perfect, but when I resize my screen, it gets all screwy, and gets really tall. Do I have to change or add something in my responsive file for this to work? Oh yeah, I make this width and height of my images (760px and 620px) in my HTML. Thanks for the help!

3 Answers

Hi Gabriel,

put all the images in separate divs. You can then add max-width: 100% to the images in your css.

<div class="site-gallery">
<img src="your image here" alt="your image" class="img-responsive">
</div>

Do this 6 times with a different image in each.

Then in your CSS try:

.img-responsive {
max-width: 100%;
}

Could you post your code? I can help you out.

Try using a relative length such as percentage.

No, here's the thing. I have absolutely no idea where to put this. In my html it looks like this: <img src="img/3934793.jpg" width="300px" height="199px" alt=""> But the width and height work perfect, but when I resize the window it gets all messed up. Any ideas?