【问题标题】:detect mobile device and if mobile use alternative css style sheet? [duplicate]检测移动设备,如果移动设备使用替代 CSS 样式表? [复制]
【发布时间】:2013-02-03 12:15:20
【问题描述】:

嗨,如果用户正在访问我的移动设备网站,​​有人可以帮我找出一种将浏览器指向替代 css 样式表的方法吗?

我曾尝试使用以下代码,但它似乎对我不起作用。有没有其他方法可以用 javascript 或其他方式做到这一点?

如果有人能告诉我一种方法,我将不胜感激,因为我所做的一切都行不通。

谢谢

<link media="only screen and (max-device-width: 480px)"
href="iPhone.css" type="text/css" rel="stylesheet" />

【问题讨论】:

标签: php css


【解决方案1】:

试试这个(从Perishable Press检索):

<link rel="stylesheet" href="http://domain.tld/screen.css" type="text/css" media="Screen" />
<link rel="stylesheet" href="http://domain.tld/mobile.css" type="text/css" media="handheld" />

media="screen" 建立联系的原因是为了解决基于 Windows 的手机的问题,该问题将使media="screen" 超过media="handheld"

【讨论】:

  • 不,我在 iphone 上测试它,这对我不起作用:/
猜你喜欢
  • 2010-09-06
  • 1970-01-01
  • 2013-03-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-04-07
  • 2015-01-06
相关资源
最近更新 更多