媒体查询在浏览器调整大小时无效 [英] Media query not taking effect on browser resize

查看:1645
本文介绍了媒体查询在浏览器调整大小时无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个网站,将使其响应。媒体查询在设备上工作,但在浏览器调整大小它不生效。这是我的代码。我错过了什么?提前感谢!

I'm working on a site that will make it responsive. Media queries are working on the device it self but on browser resize it's not taking effect. This is my code. Did I missed something? Thanks in advance!

@media only screen and (min-device-width : 320px) and (max-device-width :     
480px) and (orientation: portrait) {

  //Code Here

}

@media only screen and (min-device-width : 320px) and (max-device-width :  
480px) and (orientation: landscape) {

  //Code Here

}


推荐答案

这是因为你的目标是

It's because you are targeting device-width.

您需要将 @media queries 更改为:

@media only screen and (min-width : 320px) and (max-width :     
480px) and (orientation: portrait) {

  //Code Here

}

此外,方向在此实例中(在您的浏览器中)不起作用。

Also, the orientation won't work in this instance (in your browser).

这篇关于媒体查询在浏览器调整大小时无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆