设备尺寸参考 :Mobile devices
媒体查询类型浏览器支持情况:CSS3 Media Queries overview
jdc规范:媒体查询 _ Aotu.io - 前端代码规范

判断设备横竖屏

  1. * 横屏 */
  2. @media all and (orientation :landscape) {
  3. }
  4. /* 竖屏 */
  5. @media all and (orientation :portrait) {
  6. }

判断设备宽高

  1. /* 设备宽度大于 320px 小于 640px */
  2. @media all and (min-width:320px) and (max-width:640px) {
  3. }

判断设备像素比

  1. /* 设备像素比为 1 */
  2. @media only screen and (-webkit-min-device-pixel-ratio: 1), only screen and (min-device-pixel-ratio: 1) {
  3. }
  4. /* 设备像素比为 1.5 */
  5. @media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio: 1.5) {
  6. }
  7. /* 设备像素比为 2 */
  8. @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2) {
  9. }