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

Design

Julia Carr
Julia Carr
3,176 Points

Need help with a code challenge for flexible images, vector graphics

The question... Swap out the appropriate selector in the media query in the CSS so that the Love at First Bite SVG object still disappears when the viewport is less than 705px.

Now I wasn't sure exactly what to do because the intro id in the challenge would erase the heading too. So, I created an id specifically for the SVG image in the html and then did this under the media query. #img {display: none;} The image is gone but it's still saying that I didn't hide the image...

14 Answers

I am having trouble with this lesson as well here is the code...

#intro img { display: none; } h1 { font-size: 2.75em; }

#grid_2 omega img/love-at-first-bite.svg{ display: none; }

}

Thank you for your help.

UPDATE: I was able to figure it out.

object, image { display:none; }

Hey Kevin,

Glad you were able to work it out :D Thank you for posting your answer so other students can benefit from your solution!

Cheers!

Elizabeth

I struggled as well but here is what I got and it worked...

Under: @media screen and (max-width: 705px) {

intro img, object {

display: none; } }

Hi Julia,

Sorry that you're having trouble. Would you be able to post a link to your working code, or a screenshot, and a link to the code challenge? Also, I've re-tagged your post so the appropriate Teacher can find it. Be sure to tag your Forum posts with the appropriate topic name (like HTML or code challenge) so Teachers and Students can help you :)

Don't forget - you can always email the Support team at help(at)teamtreehouse(dot)com if you're stuck! Be sure to include a screenshot and a link to the Code Challenge. That'd be super-helpful :)

Cheers!

  • E
Allison Grayce Marshall
STAFF
Allison Grayce Marshall
Treehouse Guest Teacher

Hey Julia!

It sounds like you need to target the image specifically inside of that div, rather than all images or just the div itself. So if it has an id of "intro" for example, you'd target images inside of that div by writing your code like:

#intro img {
    display: none;
}

For it to disappear only at 705px, write that code within the media query.

Learn more about selectors here: http://teamtreehouse.com/library/websites/css-foundations/selectors

I can help you more next time if you link to a screenshot of your code and a link to the challenge like Elizabeth pointed out! Hopefully this helped :)

Allison

Hey guys. I am posting this on this one a little later but i am having this same problem.

I have inputed the following information

@media screen and (max-width : 705px) { .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%;

#intro img { display: none; }

} but i am still getting the question incorrect. Any thoughts? James Barnett Allison Grayce Marshall

James Barnett
James Barnett
39,199 Points

@Julia -

If you are still having trouble use this code playground to test out your code. Then share the link to your codepen in this thread.

James Barnett
James Barnett
39,199 Points

@Kevin -

For the Content Defined Breakpoint ...

You don't need to add a class to the love at first bite illistration. Instead just take a look at the html, and take note of ...

  • The image is inside of the intro div.
  • It's the only image inside of that div.

So in order to hide just that illustration and nothing else use ...

#intro img { display: none; }

Don't use `img { display: none; } that will incorrectly hide all of the images.


If you click the refresh preview button in the code challenge and then resize your browser until it's less than 705px wide the illistration will vanish.

The reason for this is that the code challenge's preview function is actually using your own browsers media queries, so it won't actually hide the images until you your viewport size is less than 705px wide.

Josh Reading
Josh Reading
876 Points

In the code challenge the .svg file is part of an object in index.html.

So you select the ID then your object "Image/object/etc.." then to command it to display none.

For example

#intro .object { Display: none; } 

I struggled as well but here is what I got and it worked...

Under: @media screen and (max-width: 705px) {

intro img, object {

display: none; } }

"Swap out the appropriate selector in the media query in the CSS"

When i first read this the key thing to me was "Swap Appropriate Selector" so i thought to swap the 'img' for 'object'

intro, object {

display: none; }

this works as well

intro img, object {

display: none; }

either way works,

You can target a specific image with a class. Add class to your code like this:

<object data="img/your_image_name.svg" type="image/svg+xml" class="xxx">
              <img src="img//your_image_name.gif" alt="yyy">
</object>

Then call this class under Style.css and set the code to display: none. It should be something like this:

.xxx {
     display: none;
}

It worked with me.

#intro object { Display: none; } I found that this worked. Don't forget that the image has turned into an object.

Hi,

I don't know why no code not work

@media  screen and ( max-width = 705px ) {
#intro img, object { display : none ; }
}

Also this code

@media  screen and ( max-width = 705px ) {
#intro object { display : none ; }
}

and this

@media  screen and ( max-width = 705px ) {
#intro img { display : none ; }
}