Microsoft Edge, media query doesn't work correctly

大兔子大兔子 提交于 2019-12-24 09:28:48

问题



I tested this media query successfully on Google Chrome but somehow Microsoft Edge has issues with it. Is something wrong with these queries? Or is it just a bug in Microsoft Edge?

UPDATE:
It looks like Edge needs a Class without Media Query, so I added .height-fix{height:650px} and it works.

@media all and (min-width:875px) and (max-width:980px) { 
.height-fix { 
  height : 610px; 
  } 
} 

@media all and (min-width:768px) and (max-width:875px) { 
.height-fix { 
  height : 575px; 
  } 
} 

@media (max-height:768px) and (min-width:1366px) and (max-width:1366px) { 
.height-fix { 
  height : 520px !important ; 
  } 
} 

This is the media query that doesn't work it should target devices with a height OVER 768px and a width OVER 1367px:

@media (min-height:768px) and (min-width:1367px) { 
.height-fix { 
  height : 650px; //this line doesn't apply
  } 
} 

回答1:


It looks like Microsoft Edge has an issue with media queries if there the class has no fallback

This means that if a css class is only specified inside a media query it sometimes won't work correctly.

So if the CSS looks like this:

@media (max-width(123px){
.height-fix {
  height: 650px
  }
}

it wont work. It should to look like this:

.height-fix{
height: 100px
}

@media (max-width(123px){
.height-fix {
  height: 650px
  }
}


来源:https://stackoverflow.com/questions/46131245/microsoft-edge-media-query-doesnt-work-correctly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!