检测是否使用移动设备(iOS / Android手机/平板电脑)中的浏览器 [英] Detect if a browser in a mobile device (iOS/Android phone/tablet) is used

查看:176
本文介绍了检测是否使用移动设备(iOS / Android手机/平板电脑)中的浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法检测是否使用手持式浏览器(iOS / Android手机/平板电脑)?

Is there a way to detect if a handheld browser is used (iOS/Android phone/tablet)?

我试图这样做,

width: 600px;
@media handheld { width: 300px; }

可以做到,如果是这样的话。

Can it be done and if so how?

编辑:从jmaes回答的引荐页面,我使用

edit: From the referred page in jmaes' answer I used

@media only屏幕和max-device-width:480px)

@media only screen and (max-device-width: 480px).

推荐答案

/ strong>:我现在尝试支持触摸和鼠标输入每个分辨率,因为设备景观慢慢模糊的东西之间的线条和不是触摸设备。

Update (June 2016): I now try to support touch and mouse input on every resolution, since the device landscape is slowly blurring the lines between what things are and aren't touch devices. iPad Pros are touch-only with the resolution of a 13" laptop. Windows laptops now frequently come with touch screens.

其他类似的答案(参见这个问题的其他答案) )可能有不同的方法来试图找出用户正在使用什么类型的设备,但没有一个是愚蠢的。我鼓励你检查这些答案,如果你绝对需要尝试确定该设备。

Other similar SO answers (see other answer on this question) might have different ways to try to figure out what sort of device the user is using, but none of them are fool-proof. I encourage you to check those answers out if you absolutely need to try to determine the device.

iPhones,对于一个,忽略掌上电脑查询(来源)。如果其他智能手机也会这样做,我也不会感到惊讶。

iPhones, for one, ignore the handheld query (Source). And I wouldn't be surprised if other smartphones do, too, for similar reasons.

当前用于检测移动设备的最佳方式是知道其宽度并使用相应的媒体查询抓住它。那里的链接列出了一些流行的。

The current best way that I use to detect a mobile device is to know its width and use the corresponding media query to catch it. That link there lists some popular ones. A quick Google search would yield you any others you might need, I'm sure.

对于更多特定iPhone(例如Retina显示屏),请先检查一下链接我张贴。

For more iPhone-specific ones (such as Retina display), check out that first link I posted.

这篇关于检测是否使用移动设备(iOS / Android手机/平板电脑)中的浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆