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 to Make a Website Styling Web Pages and Navigation Make a CSS Image Gallery

Holly Holliday
Holly Holliday
1,563 Points

My challenge is asking me-I don't understand. Add CSS that will allow all images to fill their parent element.

I understand that the this is asking me to have the image fill the maximum width of their container....and it's been suggested to write the code {max-width:100;} but it's not working in the code for the challenge...

css/main.css
a {
  text-decoration: none;
}

#gallery {
  margin: 0;
  padding:0;
  list-style: none;
}

#gallery 
{max-width: 100%;}

  #logo {
  text-align: center;
  margin: 0;
}

h1, h2 {
  color: #fff;
}

nav a {
  color: #fff;
}

nav a:hover {
  color: #32673f;
}

h1 {
  font-family: β€˜Changa One’, sans-serif;
  font-size: 1.75em;
  font-weight: normal;
}
Holly Holliday
Holly Holliday
1,563 Points

Thank you! We hadn't gone over in the class so it threw me off. My learning Code is better today then yesterday...

2 Answers

You can use The Following

img{
width: 100%;
height: auto;
}

this will make all the images fill the section or div or span or article they are in, you can use

max-width: 100%;
max-height: auto;

for better result ;)

your forgot to add the % sign. so the styling looks like:

max-width: 100%;