最小宽度媒体查询在 ipad 上不起作用?
为什么在横向模式下的 iPad 上无法拾取以下媒体查询?
@media all and (min-device-width: 1000px) {
css here
}
或者
@media all and (min-width: 1000px) {
css here
}
我希望这个 css 能够针对任何宽度为 1000px 或以上的浏览器,而不仅仅是 ipad。因此,如果可能的话,我宁愿使用第二个选项 min-width 而不是 min-device-width 。两个版本都可以在我的电脑上使用 Firefox 正常运行。 谢谢
Why isnt the following media query being picked up on iPads in landscape mode?
@media all and (min-device-width: 1000px) {
css here
}
Or
@media all and (min-width: 1000px) {
css here
}
I want this css to target any browser which is 1000px wide or over, not just ipads. For this reason id rather work with the 2nd option of min-width not min-device-width if possible. Both versions work fine with firefox on my PC.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
来自 http://perishablepress .com/press/2010/10/20/target-iphone-and-ipad-with-css3-media-queries/
看起来可能需要
screen
属性。From http://perishablepress.com/press/2010/10/20/target-iphone-and-ipad-with-css3-media-queries/
It looks like the
screen
attribute may be required.如果发现这对新 iPad 非常有效
If found this works great for the new iPad
根据记录,我不确定为什么
不适合你。自从这个问题首次发布以来,iPad 可能发生了一些变化吗?
这是一个有效的示例:
实时视图:http://fiddle.jshell.net/panchroma/Bn4ah/show/
编辑视图: http://fiddle.jshell.net/panchroma/Bn4ah/
另外请确保包含
在页面的头部。
For the record, I'm not sure why
didn't work for you. Possibly something changed with the iPad since this question was first posted?
Here's a working example:
live view: http://fiddle.jshell.net/panchroma/Bn4ah/show/
edit view: http://fiddle.jshell.net/panchroma/Bn4ah/
Also be sure to include
in the head of your page.
我试图使用像这样的简单媒体查询:
@media only 屏幕和(最小宽度:768px)
{此处为CSS}
但我不会在我正在测试的 iPad pro 10.5' 上触发,我将其增加到 900px(对于纵向)并且它工作得很好,我认为由于您需要补偿视网膜显示屏,它可能在旧设备上工作得很好iPad 非视网膜显示屏。
I was trying to use a simple media query like this:
@media only screen and (min-width : 768px)
{css here}
but I wouldn't trigger on an iPad pro 10.5' I was testing on, I increase it to 900px (for portrait) and it worked just fine, I think because of the retina display you need to compensate, it may work fine on old iPads non-retina.
在尝试为平板电脑编写媒体查询时,我实际上遇到了 iPad 少报其尺寸的问题。当我尝试使用
@media screen 和 ( min-width: 768px )
时,我的样式被应用到其他平板电脑设备,但被 iPad 忽略。我开始在开发人员工具中尝试响应式设备模型,并偶然发现了该解决方案。由于某种原因,当我将屏幕尺寸缩小到760px
时,我的样式将会应用。因此,我编辑了媒体查询以读取@media screen 和 ( min-width: 760px )
,一切都开始按预期工作。Trying to write a media query for tablet, I actually encountered the problem of the iPad underreporting its dimensions. When I tried to use
@media screen and ( min-width: 768px )
, my styles were being applied to other tablet devices, but ignored by the iPad. I started playing around with the Responsive device model in developer tools, and I stumbled onto the solution. For some reason, my styles would apply when I sized the screen down to760px
. So, I edited the media query to read@media screen and ( min-width: 760px )
and everything started working as expected.iPad 始终报告其宽度为 768px,高度为 1024px,因此您必须了解它如何随
orientation
旋转并使用min-device-height:1000px
像这样:结果:
使用chrome和firefox(还有人用IE吗?)
参考文献:
w3 媒体查询
Safari CSS参考
优化网页内容
The iPad is always reporting its width as 768px and its height as 1024px, so you have to find out how it is rotated with
orientation
and usemin-device-height:1000px
like so:Results:
Using chrome & firefox (does anyone even use IE anymore?)
References:
w3 media queries
Safari CSS Reference
Optimizing Web Content