仅加载ipad的css文件 [英] Load css file for ipad only
问题描述
我试图加载ipad的css文件。我试过这个:
Im trying to load a css file for ipad only. I tried this:
<link href="/css/ipad.css" rel="stylesheet" media="all and (max-device-width: 1024px)" type="text/css">
它适用于iPad,但如果我将我的分辨率降低到1024乘768在我的桌面和查看网站在firefox的ipad样式表加载以及。所以我试过:
It works for iPad but if I lower my resolution to 1024 by 768 on my desktop and view the site in firefox the ipad stylesheet loads as well. So I tried:
<link href="/css/ipad.css" rel="stylesheet" media="all and (max-device-width: 1024px) and (orientation:landscape)" type="text/css">
但仍然是同样的问题。
But still same issue. How can I make sure this stylesheet ONLY loads if they are viewing the page on a iPad?
推荐答案
您使用的是什么技术?如果您可以控制要呈现的内容(服务器端)到页面,您可以检查请求中的USER-AGENT标头。如果它包含字符串iPad,然后渲染出css标签,如果没有,不包括它。
What technology are you using? If you have control over what you are rendering (server side) to the page you can check for the USER-AGENT header in the request. If it contains the string iPad, then render out the css tag, if not, don't include it.
如果你只是传递静态html, 。
If you are just delivering static html, this will not work.
这篇关于仅加载ipad的css文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!