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

Arnold Omwango
PLUS
Arnold Omwango
Courses Plus Student 1,969 Points

Content Defined Break Points

teamtreehouse.com/library/content-defined-breakpoints

Write a media query at 705px where the layout begins to break, that forces grid_1 through grid_6 to span 100% width of the container.

I have this,

}

.grid_1 { width: 15.625%; } /* 125px/800px = 15.625% */
.grid_2 { width: 32.5%; } /* 260px/800px = 32.5% */
.grid_3 { width: 49.375%; } /* 395px/800px = 49.375% */
.grid_4 { width: 65.625%; } /* 525px/800px = 65.625% */
.grid_5 { width: 83.125%; } /* 665px/800px = 83.125% */
.grid_6 { width: 100%; } /* 800px/800px = 100% */

.grid_1,
.grid_2,
.grid_3,
.grid_4,
.grid_5,
.grid_6 {
  margin-right: 1.25%;
  float: left;
  display: block;
}
.alpha { margin-left:0; }
.omega {margin-right:0; }

4 Answers

Kevin Korte
Kevin Korte
28,149 Points

The important thing to keep in mind here is that divs in the HTML are nested. All of HTML works this way, much of it is nested.

For example, lets say I had 10 images on a webpage. If I used

img { display: none;}

I would select all 10 of the images and not display any of them. But I could look up through the HTML, and see if the image I wanted is nested inside of another div, that no other image is, and in the case of this code example that is exactly our solution.

So how to solve this. Here are the step by steps since it is so important to understand how we got to the answer, instead of just copy and paste.

1) Look at the HTML structure. 2)Find our love at first site image in the HTML. 3)Look at what our div's our image are nested inside.

The next closest div the image is nested in is grid_2 and omega. Two different class options. Are any other images nested inside either of these two classes? Answer: YES! So those can't be our solution, let's move up to the next level of nesting.

4)We can see grid_4, but looking at the HTML, grid_4 is closed before our image, so it's not an option for being a selector, since our image is not nested inside of that div. Let's move up the HTML to the next div.

5)We can see we have a div with an id of 'intro', and our image is nested inside of it. Good news, now we need to see if any other image is nested inside of this div. Are they? Answer NO! Great news! We have found our parent div that we can use as a selector.

Now we need to add that to our media query, so we write it like so:

@media screen and (max-width: 705px) { 
  .grid_1, .grid_2, .grid_3, .grid_4, .grid_5, .grid_6 { 
    width:100%; 
  }
  #intro img {
    display:none;
  }
}

And this will select all images inside of an element with the id of intro, which with this HTML mark up this will work just fine -- and this code will allow you to pass the lesson.

I normally do not give out answers this bluntly, but I don't want you to be too stuck that you quit. Keep going strong. If you're like me, you will have a moment where this stuff just start to "click" and it starts to make more sense. It's all about problem solving, and being creative, and almost always there are more than one way to skin the cat. I hope you are able to understand how we got to this answer.

Good luck, don't give up.

Kevin Korte
Kevin Korte
28,149 Points

Hi Arnold,

I do not see your media query in there.

Someone asked this same question 2 days ago, and so I'll link you over to my advice there. Good luck

https://teamtreehouse.com/forum/write-a-media-query-at-705px-where-the-layout-begins-to-break-that-forces-grid1-through-grid6-to-span-100-width-of-the-container-2?sort=subscribed

I don't know if its bad form to write this for you but this is what I used.

@media screen and (max-width: 705px;) { .grid_1, .grid_2, .grid_3, .grid_4, .grid_5, .grid_6 { width:100% } }

Arnold Omwango
Arnold Omwango
Courses Plus Student 1,969 Points

Thanks Shawn Denham, How about the second task? Add the appropriate CSS within the same media query that will force the “love at first bite” illustration to disappear. What is the answer? we are paying for this so I think I have to ask where I am stuck

You have a img tag that is nested inside divs. You have to write a selector that targets just that img and set it to: display: none;

HINT: look for a unique ID in the HTML markup!

if you need more help please let me know!

Arnold Omwango
Arnold Omwango
Courses Plus Student 1,969 Points

When I for example cut the whole div <div class="grid_2 omega"> <img src="img/love-at-first-bite.gif" alt="Love at First Bite"> from the HTML markup and refresh the browser the img. disappears. But when I paste it back and paste the same in the media query the img. shows,even with the { display: none;} at the end. Just give me the answer so I can learn how and move on. To be honest this is killing me and I need to practice more some time, but for now I need an answer. Hope its no bother

Kevin Korte
Kevin Korte
28,149 Points

You have to look at the HTML markup, and see how you can select the correct image and set it to display:none; since we already established that was what was needed.

It appears to me that that image is the only image inside of the div with an id of "intro", so inside your media query, you need to write a new selector that selects all images nested inside the div #intro and set that selector to display:none.

You will pass if you do it correctly.

Just giving you the answer will not teach you to problem solve this, which is exactly what coding is all about. And if you go through the lessons with too much copy and pasting code to pass, you're going to really get your self messed up. Not trying to be mean, but just brutally honest.

If you still can't figure it out, it may be worth your time to go back and watch the video again.

Arnold Omwango
PLUS
Arnold Omwango
Courses Plus Student 1,969 Points

Hi Kevin and Shawn, I really appreciate your help in this but I have watched the video countless times since yesterday but I am not getting it. I am trying to learn why and where I am failing but I am not getting anything. In the video, Alison does explain how to include this but in the markup I don't know which one to pick. I am about to give up this whole coding thing if by asking for help I