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

Daniel Silva
Daniel Silva
5,353 Points

Why is the img too big?

I'm creating a portfolio for school. I'm using a bootstrap template that uses a carousel of images. A link to the template I'm using can be found here: https://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_temp_marketing&stacked=h

I'm using an image of a canyon that I took with my iphone horizontally. When I upload the image, it's entirety is shown which is good, however the height is way to big. I've tried resizing my image but it doesn't work. Any ideas?

1 Answer

Steven Parker
Steven Parker
231,108 Points

I'm not sure how "resizing" it would not work, but perhaps I don't know what you mean by that.

I see that the images in the sample are 1200 x 400. Did you try resizing yours to those dimensions?

Daniel Silva
Daniel Silva
5,353 Points

I meant that I've tried making the images to 400px by 400px. I haven't resizing the image dimension to the ones in the sample yet.

Steven Parker
Steven Parker
231,108 Points

The vertical dimension is being expanded to preserve the aspect ratio. You could either constrain the height (and cause aspect distortion) or use clipping (show only part of the image).

But neither should be necessary if you resize the image to the dimensions the design is intended for.

Daniel Silva
Daniel Silva
5,353 Points

Thank you, it worked.

I have a question about setting an image to the dimensions of an element. Let's say instead of a carousel, I used a header with a background image. How do/can I figure out the dimensions of an element so I can set my images to it?

Steven Parker
Steven Parker
231,108 Points

Like the designers of that template did, you get to choose the dimensions of the element when you design a new page.