CSS规则仅适用于平板电脑和手机,而不适用于台式机?

时间:2020-05-02 14:38:12

标签: css responsive

如何制定仅适用于平板电脑和手机(不适用于台式机)的CSS规则? 如果我使用:

@media screen and (max-width: 1400px)

“屏幕”是指“浏览器窗口”,而不是“设备屏幕”。因此,如果我在桌面上缩小浏览器窗口,则会应用此CSS规则。

我发现 @media手持设备已过时。

@media screen and (max-device-width: 1400px)
根据{{​​3}}

可以正常工作,但是 device-width 似乎也已被弃用

1 个答案:

答案 0 :(得分:0)


/* 
  ##Device = Desktops
  ##Screen = 1281px to higher resolution desktops
*/

@media (min-width: 1281px) {

  //CSS

}

/* 
  ##Device = Laptops, Desktops
  ##Screen = B/w 1025px to 1280px
*/

@media (min-width: 1025px) and (max-width: 1280px) {

  //CSS

}

/* 
  ##Device = Tablets, Ipads (portrait)
  ##Screen = B/w 768px to 1024px
*/

@media (min-width: 768px) and (max-width: 1024px) {

  //CSS

}

/* 
  ##Device = Tablets, Ipads (landscape)
  ##Screen = B/w 768px to 1024px
*/

@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {

  //CSS

}

/* 
  ##Device = Low Resolution Tablets, Mobiles (Landscape)
  ##Screen = B/w 481px to 767px
*/

@media (min-width: 481px) and (max-width: 767px) {

  //CSS

}

/* 
  ##Device = Most of the Smartphones Mobiles (Portrait)
  ##Screen = B/w 320px to 479px
*/

@media (min-width: 320px) and (max-width: 480px) {

  //CSS

}


https://gist.github.com/gokulkrishh/242e68d1ee94ad05f488

相关问题