简体   繁体   English

媒体查询arent在移动设备上工作

[英]Media queries arent working on mobile

I have created a stylesheet for mobile devices. 我已经为移动设备创建了一个样式表。 Im loading it with this: 我用这个加载它:

<link rel="stylesheet" media="handheld, screen and (max-width: 650px)" href="/mobile.css?t=<?php echo rand(); ?>" />

inside that file I have: 在该文件中,我有:

@media handheld, screen and (max-width: 650px) {
     -- Styles here
}

@media handheld, screen and (max-width: 446px) {
     -- Styles here
}

It works when i resize browser, but for some reason at least on android i see the normal web, any idea? 当我调整浏览器大小时,它可以工作,但是由于某种原因,至少在android上,我可以看到正常的网络,有什么想法吗?

There are a number of reasons why this may be happening: 发生这种情况的原因有很多:

  1. Your Android doesn't support media queries. 您的Android不支持媒体查询。 There are a handful of Android devices out there that don't recognize media queries, your droid may be one of them. 那里有少数无法识别媒体查询的Android设备,您的机器人可能就是其中之一。

  2. Your media query is not being interpreted how you think it's being interpreted. 您的媒体查询没有得到您认为的解释。 Are you looking for "handheld, (screen and max-width: 650px)", or does it have to be a handheld screen with a max-width of 650px? 您是要寻找“手持式(屏幕和最大宽度:650像素)”,还是必须是最大宽度为650px的手持式屏幕? If you're expecting the first, you might actually be getting the latter. 如果您期望第一个,那么实际上您可能正在获得后者。 If that's the case, then you probably won't ever trigger that code, because very few smartphones register themselves as "handheld." 如果真是这样,那么您可能永远不会触发该代码,因为很少有智能手机将自己注册为“手持式”。

  3. Your screen width is not what you think it is. 屏幕宽度不是您所想的。 Just because you have a screen that is 1.5" by 3", it doesn't mean your resolution tops out at 650px or even 446px. 仅仅因为您的屏幕是1.5英寸乘3英寸,并不意味着您的分辨率最高可达650px甚至446px。 Thanks to the high densities that these smartphones can achieve, your droid may actually have a high resolution than your desktop monitor. 由于这些智能手机可以实现的高密度,因此您的机器人实际上可能比台式机显示器具有更高的分辨率。 The iPhone5, for example, would only read your first query and only in portrait mode, because its smallest side is 640px, with the longer side being 1136px. 例如,iPhone5仅在纵向模式下才读取您的第一个查询,因为它的最小边为640px,较长边为1136px。 The largest that the Android OS supports is a whopping 2560x1600 resolution!) Android OS支持的最大分辨率是高达2560x1600的分辨率!)

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

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