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

I set a width value and it affects the height of the picture? What am I missing?

In the "width and height" video, Guil is setting a 50px width for the vector in the header and it affects the height of the image. How is that possible?

2 Answers

Steven Parker
Steven Parker
243,656 Points

If you set only the width, the height is adjusted appropriately to maintain the aspect ratio of the image.

You can also set an explicit height if you like, but the image will then be stretched or squashed to fit.

Guil used this code:

.arrow { width: 50px; }

and the only noticeable thing that happened with the vector was that the height got a lot smaller. Why didn't the width went to 50px and it affected only the height?