简体   繁体   English

媒体查询不适用于移动设备,但在台式机上效果很好

[英]media query is not working on mobile but on desktop it works great

HTML head- HTML头

<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta name="viewport" content="maximum-scale=1">

CSS media query- CSS媒体查询-

@media handheld, screen 
  and (min-width: 200px)
  and (max-width: 399px){}

我不知道您为什么使用掌上电脑。

@media only screen and (min-width:300px) and (max-width :399px) { }

First, handheld is not supported by most mobile browsers, you can see more from this question: Do iPhone / Android browsers support CSS @media handheld? 首先,大多数移动浏览器不支持handheld ,您可以从以下问题中了解更多信息: iPhone / Android浏览器是否支持CSS @media手持设备?

Second, the breakpoint of your @media doesn't quite match any mobile screen size, here a website listing media queries for standard devices that your can check on: https://css-tricks.com/snippets/css/media-queries-for-standard-devices/ 其次,你的断点@media并不十分任何手机屏幕大小相匹配,在此网站列出媒体查询标准的设备,你可以检查: https://css-tricks.com/snippets/css/media-queries -对于标准设备/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM