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 trialRay Kennedy
Courses Plus Student 2,982 Pointswhen using g percentage instead of px, you only need to specify width of the element and not the height?
you only need to have the width in percentage and not the the height for the element to scale properly? be cause in the video he does nothing to the pictures height only the width
3 Answers
Iain Simmons
Treehouse Moderator 32,305 PointsIf you leave the height
as the default auto
, it will keep the image's correct aspect ratio. Otherwise it will stretch the image based on the percentage of the containing element.
Jason Anello
Courses Plus Student 94,610 PointsHi Ray,
That's correct. The browser will automatically scale the height proportionally for you as the width of your image changes.
ellie adam
26,377 PointsHi Ray,
When we design for small devices we use % for width. If screen is hundred % we may want picture 50 % or 60 % it depends.