2013-02-18 61 views
0

嗨可以有人请帮助我想找出一种方法,指向浏览器的另一种CSS样式表,如果用户正在访问我的移动设备的网站?检测移动设备,如果移动使用替代的CSS样式表?

我试过使用下面的代码,但它似乎并没有为我工作。有没有其他的方式来做到这一点,也许在JavaScript或其他方式?

我真的很感激,如果有人能告诉我一个这样做的方式,因为我所有的一切都不起作用。

感谢

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

使用“标准”设备宽度作为断点并不是一个好主意:http://blog.cloudfo ur.com/the-ems-have-it-proportional-media-queries-ftw/ and http://designshack.net/articles/css/responsive-design-why-youre-doing-it-wrong/ – cimmanon 2013-02-18 23:44:40

回答

0

试一下这个(从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"

+0

nope am在iPhone上测试它,这不是为我工作:/ – 2013-02-18 23:17:19