So, I immersed myself in Responsive Design and got a clear idea of how this works. However, there are two things that I need to lower my head.
My logical thinking is this: if the screen size is less than 320 pixels, then do A, if the screen size is less than 480 pixels, do B.
@media only screen and (max-width: 320px) { Do one thing here} @media only screen and (max-width: 480px) { Do another thing here}
The problem is that css in max-width: 480px also affects if the screen width is less than 320.
When I look at the examples, I see that they use something like:
@media only screen and (min-width: 290px) {} @media only screen and (min-width: 544px) {} @media only screen and (min-width: 960px) {}
This basically means that the screen is larger than 290 pixels, do it, and if the screen is larger than 544 pixels, do it. But I will have the same problem. The code in min-width: 290px will also be used for any screen size exceeding 290px.
So, the only solution I can think of will only work for a specific range of the screen, using this:
@media only screen and (max-width: 320px) {} @media only screen and (min-width: 321px), only screen and (max-width: 480px){} @media only screen and (min-width: 640px), only screen and (max-width: 481px){}
Can anyone advise me on this?
Looking at the examples, I see the extraction of "redundant" code. Most of the same code repeats, just having different meanings:
@media only screen and (max-width : 930px), only screen and (max-device-width : 930px){ nav li a { width: 25%; border-bottom: 1px solid #fff; font: 400 11px/1.4 'Cutive', Helvetica, Verdana, Arial, sans-serif; } nav li:last-child a, nav li:nth-child(4) a { border-right: none; } nav li:nth-child(5) a { border-bottom: none; } } @media only screen and (max-width : 580px), only screen and (max-device-width : 580px){ nav li a { width: 50%; font: 400 12px/1.4 'Cutive', Helvetica, Verdana, Arial, sans-serif; padding-top: 12px; padding-bottom: 12px; } nav li:nth-child(even) a { border-right: none; } nav li:nth-child(5) a { border-bottom: 1px solid #fff; } }
For large sites, I can imagine that this will create a lot of code and large CSS files.
Is this the new standard as we need to work with responsive design?
Can the following be done ?:
@media only screen and (min-width: 640px) { @import url("css/640.css");}