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
Amandeep Dindral
8,915 Pointsdesktop media query making mobile media query styles disappear
I have all my mobile styles sitting in a media query set to @media (max-width: 400px) {}. Then I have all my desktop styling sitting in a media query set to @media (min-width: 400px) {}. When I use display:none to cover up some of the mobile styles that I dont want to showing up on desktop they disappear from the mobile view as well. Any one have any idea why?
2 Answers
Henrik Christensen
Python Web Development Techdegree Student 38,322 Pointscould you try link your code?
Henrik Christensen
Python Web Development Techdegree Student 38,322 PointsNot sure but I have a feeling that it might be because the @media is overlapping each other at 400px.
If I may give a suggestion: If you are doing the mobile-first approach I would make the css for mobile first (no media query) and then add media queries when you've finished the "stanard" styling:
/*****
write your standard css in here
*****/
/****
here you start adding media queries for new screen sizes
****/
This is just a suggestion cause I've never seen it done like in your example before :-)
Amandeep Dindral
8,915 PointsAmandeep Dindral
8,915 PointsSo there are two media queries. The top is for desktop and the bottom is for mobile. Now if I do a display:none in the desktop media query to remove mobile styling I dont want showing it removes it from the mobile view as well.