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

Hiding a div using media queries

I'm trying to hide a div when a user is accessing a website from a mobile device. However, I can't seem to get it to work:

@media screen and (min-width: 480px) {

/**************************

Mobile **************************/ #logo-name { display: none; } }

@media screen and (min-width: 660px) {

   /**************************

Desktop **************************/ #logo-name { display:block; } }

Any ideas?

2 Answers

Samuel Rueby
Samuel Rueby
22,538 Points

Your phone can probably display 480 pixels, which is why it's not working. Bootstrap considers "small" devices to to be able to display 768 pixels. Try targeting devices that display less than 768 pixels for mobile devices. (max-width: 767)

Thank you so much. It works :-)

Samuel Rueby
Samuel Rueby
22,538 Points

Up-vote this answer if it was helpful!