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 How to Make a Website Responsive Web Design and Testing Build a Three Column Layout

"nth-child" Pseudo-Class

I have recently watched this video (link attached) on which they introduced the "nth-child" pseudo-class. Now, inside the parentheses is written "4n"; however, if the "n" is an index (as I understand this), then I believe that they were supposed to write "3n+1" inside the parentheses, or else there will a bug once there will be 3 rows and more. Could this be right or should I just review this lesson again?

2 Answers

You're correct Asaf. This is noted in the Teacher's Notes section.

The "bug" really only happens when you have a taller caption come before a shorter caption in a given row. The next row is going to have problems. The first item in the next row won't float all the way to the left but it will stop when it hits the taller item from the row above.

If all of the items were guaranteed to have equal height then we wouldn't have to do any clearing at all. Here we have captions that are fluid width and are going to wrap differently and hence have different heights. A relatively short caption with big words is going to wrap to more lines than a caption with shorter words.

This also happens in the two column layout which to my knowledge doesn't have a correction yet.

I wrote more about it in this thread:
https://teamtreehouse.com/forum/3-column-layout-nth-clear-not-working

Thank you very much, plus I haven't known there is a "Teacher's Notes" section. P. S After I had seen the other thread, I realised immediately how much dedication you put in writing these answers, and I truly appreciate you for that and for your help.

You're very welcome.

Richard Duncan
Richard Duncan
5,568 Points

There won't be a bug as such it may not target the elements that you're aiming for though. The two equations are different. Math was never my strong suit but as I understand it: -

4n is every 4th starting at 0, e.g. 4...8...12....

3n is every third starting at 1 e.g. 1...4...7...