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

HTML

Error when displaying more than six images.

I am going through the html section where the portfolio site is made. I was trying to create more than six images just to see if it could be done. After you create image number seven it messes up and no longer displays correctly. Images eight and nine are displayed below image number seven instead of beside. Has this happened to anyone else? I can attach my code if needed.

Here is the code that I currently have. I have just used one image nine different times as a test.

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Brandon Whisnant | Developer</title> <link rel = "stylesheet" href = "css/normalize.css"> <link href='http://fonts.googleapis.com/css?family=Ubuntu|Yanone+Kaffeesatz' rel='stylesheet' type='text/css'> <link rel = "stylesheet" href = "css/main.css"> <link rel = "stylesheet" href = "css/responsive.css"> <meta name = "viewport" content = "width = device-width, initial-scale = 1.0">

</head> <body> <header> <a href="index.html" id = "logo"> <h1>Brandon Whisnant</h1> <h2>Developer</h2> </a> <nav> <ul> <li><a href="index.html" class = "selected">Portfolio</a></li> <li><a href="about.html">About</a></li> <li><a href="contact.html">Contact</a></li>

    </ul>

  </nav>

</header>
<div id = "wrapper">
  <section>
   <ul id = "gallery">

     <li>
        <a href = "numbers-01.jpg">
          <img src = "img/numbers-01.jpg" alt = "">
          <p>Experimentation with color and texture</p>
        </a>
      </li>

    <li>
        <a href = "numbers-01.jpg">
          <img src = "img/numbers-01.jpg" alt = "">
          <p>Experimentation with color and texture</p>
        </a>
    </li>

    <li>
        <a href = "numbers-01.jpg">
          <img src = "img/numbers-01.jpg" alt = "">
          <p>Experimentation with color and texture</p>
        </a>
      </li>

    <li>
        <a href = "numbers-01.jpg">
          <img src = "img/numbers-01.jpg" alt = "">
          <p>Experimentation with color and texture</p>
        </a>
      </li>

    <li>
        <a href = "numbers-01.jpg">
          <img src = "img/numbers-01.jpg" alt = "">
          <p>Experimentation with color and texture</p>
        </a>
      </li>

    <li>
        <a href = "numbers-01.jpg">
          <img src = "img/numbers-01.jpg" alt = "">
          <p>Experimentation with color and texture</p>
        </a>
      </li>

    <li>
        <a href = "numbers-01.jpg">
          <img src = "img/numbers-01.jpg" alt = "">
          <p>Experimentation with color and texture</p>
        </a>
    </li>

    <li>
        <a href = "numbers-01.jpg">
          <img src = "img/numbers-01.jpg" alt = "">
          <p>Experimentation with color and texture</p>
        </a>
    </li>

    <li>
        <a href = "numbers-01.jpg">
          <img src = "img/numbers-01.jpg" alt = "">
          <p>Experimentation with color and texture</p>
        </a>
    </li>
    </ul>

  </section>
</div>

</body> </html>

1 Answer

Hello Brandon,

I admit I am a newbie, but I think I have the answer to your question. The problem is in the nth-child gallery statement inside the responsive.css. If you follow the example in the video, you are told to add the following.

#gallery li:nth-child(4n) {
    clear: left; 
  }

This clears the 4th, 8th, 12th element, and so on. But for a three column layout what you want is to clear the 4th, 7th, 10th and so on. I tried changing the css to the snippet below, and it seemed to work.

#gallery li:nth-child(3n+1) {
    clear: left; 
  }

That totally worked!! Thank you so much! That has been frustrating me for about an hour and a half now. I really appreciate your help.

Glad to help. Yay for experimentation!