CSS Media Queries


/ Published in: CSS
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <!-- in head -->
  2. <link rel="stylesheet" href="smartphone.css"
  3. media="only screen and (min-device-width : 320px)
  4. and (max-device-width : 480px)">
  5.  
  6. <link rel="stylesheet" href="smartphone-landscape.css"
  7. media="only screen and (min-width : 321px)">
  8.  
  9. <link rel="stylesheet" href="smartphone-portrait.css"
  10. media="only screen and (max-width : 320px)">
  11.  
  12. <link rel="stylesheet" href="ipad.css"
  13. media="only screen
  14. and (min-device-width : 768px)
  15. and (max-device-width : 1024px)">
  16.  
  17. <link rel="stylesheet" href="ipad-landscape.css"
  18. media="only screen
  19. and (min-device-width : 768px)
  20. and (max-device-width : 1024px)
  21. and (orientation : landscape)">
  22.  
  23. <link rel="stylesheet" href="ipad-portrait.css"
  24. media="only screen
  25. and (min-device-width : 768px)
  26. and (max-device-width : 1024px)
  27. and (orientation : portrait)">
  28.  
  29. <link rel="stylesheet" href="widescreen.css"
  30. media="only screen and (min-width : 1824px)">
  31.  
  32. <link rel="stylesheet" href="iphone4.css"
  33. media="only screen
  34. and (-webkit-min-device-pixel-ratio : 1.5),
  35. only screen and (min-device-pixel-ratio : 1.5)">
  36. <!-- head -->
  37.  
  38. /* Smartphones (portrait and landscape) ----------- */
  39. @media only screen and (min-device-width : 320px) and (max-device-width : 480px) {
  40. /* Styles */
  41. }
  42.  
  43. /* Smartphones (landscape) ----------- */
  44. @media only screen and (min-width : 321px) {
  45. /* Styles */
  46. }
  47.  
  48. /* Smartphones (portrait) ----------- */
  49. @media only screen and (max-width : 320px) {
  50. /* Styles */
  51. }
  52.  
  53. /* iPads (portrait and landscape) ----------- */
  54. @media only screen and (min-device-width : 768px) and (max-device-width : 1024px) {
  55. /* Styles */
  56. }
  57.  
  58. /* iPads (landscape) ----------- */
  59. @media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) {
  60. /* Styles */
  61. }
  62.  
  63. /* iPads (portrait) ----------- */
  64. @media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) {
  65. /* Styles */
  66. }
  67.  
  68. /* Desktops and laptops ----------- */
  69. @media only screen and (min-width : 1224px) {
  70. /* Styles */
  71. }
  72.  
  73. /* Large screens ----------- */
  74. @media only screen and (min-width : 1824px) {
  75. /* Styles */
  76. }
  77.  
  78. /* iPhone 4 and high pixel ratio devices ----------- */
  79. @media
  80. only screen and (-webkit-min-device-pixel-ratio : 1.5),
  81. only screen and (min-device-pixel-ratio : 1.5) {
  82. /* Styles */
  83. }

URL: http://stuffandnonsense.co.uk/blog/about/hardboiled_css3_media_queries

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.