简体   繁体   English

@media screen CSS属性没有响应?

[英]@media screen css property doesn't respond?

My @media screen and (max-device-width: 640px) doesn't seem to respond. 我的@media屏幕和(最大设备宽度:640像素)似乎没有响应。 I also put the 我也把

<link rel="stylesheet" type="text/css" href="css/mobile.css"/>

and the

<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0" />

in my Index.html. 在我的Index.html中。

I only have this in my mobile.css: 我的mobile.css中只有这个:

 @media screen and (max-device-width: 640px)
 {
 #navbar {
     height: 11%;   
     }
 }

What do I miss? 我想念什么? I work btw in dreamweaver cs4. 我在Dreamweaver CS4中工作。

max-device-width and/or min-device-width needs an actual device to take effect, to debug your code on desktop you need to use: max-device-width和/或min-device-width需要实际的设备才能生效,要在台式机上调试代码,您需要使用:

@media screen and (max-width: 640px) {

  #navbar {
    height: 11%;    
  }

}

Try Device Emulator in Chrome Browser , 在Chrome浏览器中尝试设备模拟器

if you develop for mobile devices, but don't have one to test on, It provides presets of existing devices (iPhone, HTC, Google...) and allows to edit resolution, orientation etc. 如果您是为移动设备开发的,但没有一款可以进行测试,它会提供现有设备(iPhone,HTC,Google ...)的预设,并允许编辑分辨率,方向等。

i'm think this... 我觉得这个...

 #navbar {
     height: 11%;   
     max-height:11%;
     }

so it never going to revase the max height 所以它永远不会改变最大高度

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM