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 trialgnguimbipro
1,068 PointsHow to "Add CSS that will allow all images to fill their parent element." ?
I'm not sure what do here.
I used the selector img with a property max-width but not sure what value needs to be used.
img { max-width: ; }
1 Answer
Daniel Houghton
4,334 PointsHey there the max-width property can be used with % or px i.e. :
/* to give a max width of the picture which is equal to half the element, this is used to keep the ratio the same when the screen size is changed */
img { max-width: 50%; }
/* to give the max width of 20 pixels, this will lock the image to a maximum of 20 pixels "/
img { max-width: 20px; }
gnguimbipro
1,068 PointsThank you so much Daniel! I was able to resolve the issue and learned something along the way :)
Christopher Lebbano
15,338 PointsChristopher Lebbano
15,338 PointsSo max-width is just saying how wide it can possibly be. This is different than just "width", which says what the width should be. If you set the width property to 100%, it should be as wide as 100% of it's parent element.