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
Unsubscribed User
1,624 PointsTroubles with implementing media queries/ 2. task in quiz
Hi, guys. I´m taking the quiz for implementing media queries. At the second task I don´t know what I´m doing wrong. Hope you can help me.
- Task: Add the appropriate CSS code to the media query so that ".contact" and ".menu" fill the entire container width when the device or browser width is at most 480px wide.
I wrote:
/* Mobile ----------- */ @media screen and (max-width : 480px) {
.grid_1,
.grid_2,
.grid_3,
.grid_4,
.grid_5,
.grid_6,
.grid_7,
.grid_8,
.grid_9,
.grid_10,
.grid_11,
.grid_12 {
width: 100%;
}
#contact {
max-width: 100%;
}
#menu {
max-width: 100%;
}
}
With and without the #menu/ #contact it doesn´t work.
26 Answers
Mansoor Bahramand
4,872 PointsWell there is two things wrong with your code!
Your selecting a ID instead of a class (id= "#" class=".") in the instructions it states to select the CLASS of "contact" and "menu" so switch the "#" to "."
Your telling the browser that the element is allow to go to the max-width of 100%. You need to tell the browser you want the elements to be 100% so change the CSS to width: 100% on both elements
I hope this helps and explains whats going on! :)
Unsubscribed User
1,624 PointsOh, thank you. That explains it pretty good.
So now I write this in the thirt task, in which you have to hide the cupcake-div.
.cupcake { display: none; }
But neither "." nor "#" works. What do I do wrong?
Mansoor Bahramand
4,872 PointsWhat are the instructions exactly?
Unsubscribed User
1,624 PointsAdd the appropriate CSS code to the media query so that images within the ".cupcake" div disappear when the device or browser width is at most 480px wide.
Mansoor Bahramand
4,872 Pointsmake sure the cupcake div is inside the media query the code is valid just make sure your placing it in the right area
Unsubscribed User
1,624 PointsLike this?:
/* Mobile ----------- */ @media screen and (max-width : 480px) {
.grid_1,
.grid_2,
.grid_3,
.grid_4,
.grid_5,
.grid_6,
.grid_7,
.grid_8,
.grid_9,
.grid_10,
.grid_11,
.grid_12 {
width: 100%;
}
.contact { width: 100%; }
.menu { width: 100%; }
#cupcake { display: none; } }
Mansoor Bahramand
4,872 Pointschange the "#" to "."
Unsubscribed User
1,624 PointsThat doesn´t work :(
Unsubscribed User
1,624 Points/* Mobile ----------- */ @media screen and (max-width : 480px) {
.grid_1,
.grid_2,
.grid_3,
.grid_4,
.grid_5,
.grid_6,
.grid_7,
.grid_8,
.grid_9,
.grid_10,
.grid_11,
.grid_12 {
width: 100%;
}
.contact { width: 100%; }
.menu { width: 100%; }
.cupcake { display: none; }
}
Mansoor Bahramand
4,872 Pointsthats because all of your code is out side the media query
Mansoor Bahramand
4,872 Points? possibly
Unsubscribed User
1,624 PointsHm, you mean the { } that define the
/* Mobile ----------- */ @media screen and (max-width : 480px)
?
No, the braces frame the tag. The grids, the .contact, .menu and .cupcake.....sorry, in my last post there is one brace at the end missing, but it´s there in the code and closes the tag.
Mansoor Bahramand
4,872 Points@media screen andn (max-width: 480px) { .grid_1, .grid_2, .grid_3, .grid_4, .grid_5, .grid_6, .grid_7, .grid_8, .grid_9, .grid_10, .grid_11, .grid_12 { width: 100%; } .contact { width: 100%; }
.menu { width: 100%; }
.cupcake { display: none; }
}
try this!
Unsubscribed User
1,624 PointsNope. Still not working....
ian ewert
5,655 PointsI am having the same problem I have tried many different things and just not understanding part 3 of the quiz. PLEASE HELP
James Barnett
39,199 Points@ian - Create a new thread and post what code you have so far. Remember to indent each line of your code with 4 spaces so the forum will format it correctly.
ian ewert
5,655 Points/* Mobile ----------- */
@media screen and (max-width : 480px) {
.grid_1,
.grid_2,
.grid_3,
.grid_4,
.grid_5,
.grid_6,
.grid_7,
.grid_8,
.grid_9,
.grid_10,
.grid_11,
.grid_12{
width:100%;}
.cupcake{
display: none;}
.contact {
width: 100%;
}
.menu {
width: 100%;
}
}
This is the code that I have. I have tried this also as #cupcake.
Noah Ojai
1,806 PointsI'm also not seeing how this works. The video wasn't effectively explicative of all this.
I would appreciate some assistance, reviewing the video over and over again has not yielded more clarity.
Thanks. This is what I have:
@media screen and (max-width : 480px) {
.menu,
.contact {
width: 100%;
}
.cupcake {display: none;
}
}
Any suggestions?
Prashant Dang
1,994 PointsNoah, hope you were able to solve the quiz. Use the following code in media query:
.cupcake img{display: none;}
Nehemiah Owens
3,645 Points.cupcake img {
display: none;
}
James Barnett
39,199 PointsNoah - Build a Responsive Website is an intermediate course. If you are a little fuzzy on some of the details of CSS, now might be a good time to check out the CSS Foundations course.
Noah Ojai
1,806 PointsThanks James!
Daniel Rossiter
Courses Plus Student 826 PointsThis helps everthing
John Faught
3,484 PointsThe correct code for the Challenge is
/* Mobile ----------- */ @media screen and (max-width : 480px) { .contact{ width:100%;} .menu{width:100%} }
Aaron Chiandet
9,826 PointsI too have had countless issues with this task and I keep seeing the same suggestions to take CSS Foundations over again in every thread.
In the future it would be helpful to the users to if you would address the questions at hand rather than diverting to other course work. From one google search I found 4 threads on this exact task and only one person mentioned the img part of .cupcake img { display: none;}
Unfortunately this was not my issue however it was everyone else's in each of those threads. Fortunately I have resolved my issue thanks to a forum poster on this thread.
James Barnett
39,199 Points> I keep seeing the same suggestions to take CSS Foundations over again in every thread.
> In the future it would be helpful to the users to if you would address the questions at hand rather than diverting to other course work.
It appears you did the courses in the recommended sequence so that advice wasn't targeted at you.
> From one google search I found 4 threads on this exact task and only one person mentioned the img part of .cupcake img { display: none;}
> Unfortunately this was not my issue however it was everyone else's in each of those threads.
Don't forget the first rule of forums, Your issue, Your Code, Your Thread that way you get advice related to the issues you are having and not trying to follow red herring of advice directed towards other people.
Omh MG
19,233 PointsMy question was: Add the appropriate CSS code to the media query so that ".contact" and ".menu" fill the entire container width when the device or browser width is at most 480px wide. Here is the way the code should look like if you're being stumped by this question.
/* Mobile ----------- */ @media screen and (max-width : 480px) { .contact{ width:100%;} .menu{width:100%}
Ross Jackson
4,700 PointsThis the solution to this task:
@media screen and (max-width : 480px) { .contact{ width:100%;} .menu{width:100%} }
That is all that it is required.
James Barnett
39,199 PointsRemember our goal here on the forum is give help not answers, next time try giving an explanation and/or a hint instead.
Need more explanation on the distinction check this out.
As a side note, I'm kinda confused on why you have randomly posted an answer to a code challenge in a thread that is 9 months old.
Ross Jackson
4,700 PointsI don't see why not to post to it if someone else will be searching for the same information in the present or future.
As an explanation for above:
The main issues most posters in here seemed to be facing was that the attributes they were trying to style within the media query were not contained within in the media query
i.e. within the { } following the media query declaration.
Also it was noted some had used # when trying to select the div where it should have been (.) to select the class. (A point alone with no set of brackets/parentheses).
Hope this clears up any confusion.
James Barnett
39,199 Points> I don't see why not to post to it if someone else will be searching for the same information in the present or future.
Because the goal of the forum is to give help not answers. Don't provide someone with just the answer - explain the process, and help guide them through understanding the problem.
If you are still unclear on the distinction between giving help and posting answer please check out this FAQ.
Let me know if you have any addition questions about how to best help other users here on the forum.
Ross Jackson
4,700 PointsAs an explanation for above:
The main issues most posters in here seemed to be facing was that the attributes they were trying to style within the media query were not contained within in the media query
i.e. within the { } following the media query declaration.
Also it was noted some had used # when trying to select the div where it should have been (.) to select the class. (A point alone with no set of brackets/parentheses).
{Because the goal of the forum is to give help not answers. Don't provide someone with just the answer - explain the process, and help guide them through understanding the problem.}
As I attempted to rectify with the above. I can't unscramble the egg. Feel free to remove the post if you feel it necessary.
I have no questions for you.
Thanks.
Robert Brown
12,269 PointsThis what I got for part 2 and 3. 2 keep it DRY. Don't over think it.
@media screen and (max-width : 480px) { .contact, .menu { width: 100%; } .cupcake img { display: none; } }