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 CSS Basics (2014) Enhancing the Design With CSS Media Query Basics

Miguel Nunez
Miguel Nunez
3,266 Points

Is this wrong?

I used this in the past sometimes it work sometimes it doesnt @media only screen (min-width : 320px) and (max-width : 736px) {

What i'm trying to do is do a range from of 320px to 736px which helped me in the past where it worked to the point where all smart phones it worked for why does this work some times

Alec Gillanders
Alec Gillanders
19,548 Points

Hi,

It depends on the outcome you are after?

The best approach is to build with 'mobile first'. So start with a layout designed for mobiles and use the @media features to change the layout at specified breakpoints and build up from there. In my opinion it makes things clearer and easier to track changes.

hope this helps?

Miguel Nunez:

If you're using a max-width: 736px in a media query, you're restricting or limiting your viewport to the maximum width of 736px, even if the viewport (screen size) is larger than that. Since screen sizes are so varied, you want your web site to be seen on mobile phones, tablets, & desktops, too. You'll need to keep this concept in mind as you design your web site.

1 Answer

Steven Parker
Steven Parker
231,261 Points

It could be a browser compatibility issue.

If the "sometimes" means "on certain browsers" that could be the reason. Or is it possible that sometimes the viewport size falls outside this range?