CSS Snippets: Media Queries

We’ve come to a point in web development where if you’re not creating or designing sites that are mobile friendly and responsive, you’re doing something wrong. Responsive design is no-longer optional, as more and more users continue to access the internet via their mobile devices. If you’re just getting started with mobile development (or even if you’ve been creating mobile web-apps for years), you may find this snippet of typical breaking points of different mobile devices super helpful to use in your media queries:

 

Join us in our newest publication:
  1. /* Smartphones (portrait and landscape) ----------- */</code></p>
  2. <p class="line number2 index1 alt1"><code class="css plain">@media only </code><code class="css value">screen</code></p>
  3. <p class="line number3 index2 alt2"><code class="css plain">and (min-device-width : </code><code class="css value">320px</code><code class="css plain">) and (max-device-width : </code><code class="css value">480px</code><code class="css plain">) {</code></p>
  4. <p class="line number4 index3 alt1"><code class="css spaces">  </code><code class="css comments">/* Styles */</code></p>
  5. <p class="line number5 index4 alt2"><code class="css plain">}</code></p>
  6. <p class="line number6 index5 alt1"></p>
  7. <p class="line number7 index6 alt2"><code class="css comments">/* Smartphones (landscape) ----------- */</code></p>
  8. <p class="line number8 index7 alt1"><code class="css plain">@media only </code><code class="css value">screen</code> <code class="css plain">and (min-width : </code><code class="css value">321px</code><code class="css plain">) {</code></p>
  9. <p class="line number9 index8 alt2"><code class="css spaces">  </code><code class="css comments">/* Styles */</code></p>
  10. <p class="line number10 index9 alt1"><code class="css plain">}</code></p>
  11. <p class="line number11 index10 alt2"></p>
  12. <p class="line number12 index11 alt1"><code class="css comments">/* Smartphones (portrait) ----------- */</code></p>
  13. <p class="line number13 index12 alt2"><code class="css plain">@media only </code><code class="css value">screen</code> <code class="css plain">and (max-width : </code><code class="css value">320px</code><code class="css plain">) {</code></p>
  14. <p class="line number14 index13 alt1"><code class="css spaces">  </code><code class="css comments">/* Styles */</code></p>
  15. <p class="line number15 index14 alt2"><code class="css plain">}</code></p>
  16. <p class="line number16 index15 alt1"></p>
  17. <p class="line number17 index16 alt2"><code class="css comments">/* iPads (portrait and landscape) ----------- */</code></p>
  18. <p class="line number18 index17 alt1"><code class="css plain">@media only </code><code class="css value">screen</code> <code class="css plain">and (min-device-width : </code><code class="css value">768px</code><code class="css plain">) and (max-device-width : </code><code class="css value">1024px</code><code class="css plain">) {</code></p>
  19. <p class="line number19 index18 alt2"><code class="css spaces">  </code><code class="css comments">/* Styles */</code></p>
  20. <p class="line number20 index19 alt1"><code class="css plain">}</code></p>
  21. <p class="line number21 index20 alt2"></p>
  22. <p class="line number22 index21 alt1"><code class="css comments">/* iPads (landscape) ----------- */</code></p>
  23. <p class="line number23 index22 alt2"><code class="css plain">@media only </code><code class="css value">screen</code> <code class="css plain">and (min-device-width : </code><code class="css value">768px</code><code class="css plain">) and (max-device-width : </code><code class="css value">1024px</code><code class="css plain">) and (orientation : </code><code class="css value">landscape</code><code class="css plain">) {</code></p>
  24. <p class="line number24 index23 alt1"><code class="css spaces">  </code><code class="css comments">/* Styles */</code></p>
  25. <p class="line number25 index24 alt2"><code class="css plain">}</code></p>
  26. <p class="line number26 index25 alt1"></p>
  27. <p class="line number27 index26 alt2"><code class="css comments">/* iPads (portrait) ----------- */</code></p>
  28. <p class="line number28 index27 alt1"><code class="css plain">@media only </code><code class="css value">screen</code> <code class="css plain">and (min-device-width : </code><code class="css value">768px</code><code class="css plain">) and (max-device-width : </code><code class="css value">1024px</code><code class="css plain">) and (orientation : </code><code class="css value">portrait</code><code class="css plain">) {</code></p>
  29. <p class="line number29 index28 alt2"><code class="css spaces">  </code><code class="css comments">/* Styles */</code></p>
  30. <p class="line number30 index29 alt1"><code class="css plain">}</code></p>
  31. <p class="line number31 index30 alt2"></p>
  32. <p class="line number32 index31 alt1"><code class="css comments">/* Desktops and laptops ----------- */</code></p>
  33. <p class="line number33 index32 alt2"><code class="css plain">@media only </code><code class="css value">screen</code> <code class="css plain">and (min-width : </code><code class="css value">1224px</code><code class="css plain">) {</code></p>
  34. <p class="line number34 index33 alt1"><code class="css spaces">  </code><code class="css comments">/* Styles */</code></p>
  35. <p class="line number35 index34 alt2"><code class="css plain">}</code></p>
  36. <p class="line number36 index35 alt1"></p>
  37. <p class="line number37 index36 alt2"><code class="css comments">/* Large screens ----------- */</code></p>
  38. <p class="line number38 index37 alt1"><code class="css plain">@media only </code><code class="css value">screen</code> <code class="css plain">and (min-width : </code><code class="css value">1824px</code><code class="css plain">) {</code></p>
  39. <p class="line number39 index38 alt2"><code class="css spaces">  </code><code class="css comments">/* Styles */</code></p>
  40. <p class="line number40 index39 alt1"><code class="css plain">}</code></p>
  41. <p class="line number41 index40 alt2"> 
Use these media queries to make sure that your design is sized correctly and has the right breaking points for as many devices as possible!

Share and Enjoy !

0Shares
0 0