【发布时间】:2015-06-10 03:34:16
【问题描述】:
我花了几天的时间来寻找使用 UIwebview 进行 ipad 媒体查询的解决方案。 我尝试过设备纵横比、不同的最小/最大宽度或设备宽度。 在 Xcode 中,模拟器或我的 Ipad 似乎就像 Iphone 一样。 加载到我的域中的网页在 ipad 上正常运行。
看来问题出在xcode
我有
<meta name="viewport" content="width=device-width ">
在html页面中
CSS:
@media all
and (max-width: 667px)
{
body::before{ content: "phone fired"}
h1{
color: #F0F;
}
}
@media all
and (min-width: 768px)
and (max-width: 1024px)
{
body::before{ content: "ipad fired"}
h1{
color: #F0F;
}
}
如果我从 css 中取出 min-width: 768px,Iphone 和 Ipad 都会显示 Ipad,因为 Iphone 在 1024px 内; 使用 min-width: 768px 时,Iphone 动作正确,但 Ipad 显示“电话已启动”。它的作用就像它的宽度小于 768px
【问题讨论】:
-
尝试使用 WURFL 来检测 iPhone / iPad 并为其运行单独的代码。 wurfl.js
-
D4Rk 的回答成功了。我的目标设备是 Iphone,所以一切都像 iphone。