Respond.JS 在 IE 8 中不起作用 [英] Respond.JS Not Working in IE 8
问题描述
出于某种原因,响应 JS 似乎不起作用.我在 IE 8 中使用媒体查询来更改各种尺寸显示器的背景图像.在 IE 8 中没有背景,只有纯色.
For some reason it appears that respond JS isn't working. I am using Media Queries in IE 8 to change background images for various size monitors. In IE 8 there is no background, just a solid color.
代码如下:
<!--[if lt IE 9]>
<script type="text/javascript" src="/js/html5-shiv.min.js"></script>
<script type="text/javascript" src="/js/respond.min.js"></script>
<![endif]-->
媒体查询如下所示:
@media (min-width:769px) and (max-width:1366px){
html, body{
background: url(/images/backgrounds/1366-bg.jpg) no-repeat center top fixed #190303;
background-size:100% auto;
}
}
上述代码在 IE 8 中无法运行是否有原因?我应该尝试使用另一个 JS 来使 IE 8 媒体查询工作吗?
Is there a reason the above code would not work in IE 8? Is there another JS that I should try to use to make IE 8 Media Queries Work?
注意:看来 html5-shiv 确实有效.我正在实时 Web 服务器上进行测试.
Note: It appears that the html5-shiv does work. I am testing on a live web server.
推荐答案
同样的问题.我发现这是我的加载顺序问题,因为我写了内联 CSS 然后我调用了响应 js 脚本,所以它看起来像
Same problem. I found out it's my loading sequence problem, because I write CSS inline and then I call respond js script, so it looks like
<script type="text/javascript" src="js/respond.min.js"></script>
<link rel="stylesheet" type="text/css" href="style.css" media="screen"/>
应该是
<link rel="stylesheet" type="text/css" href="style.css" media="screen"/>
<script type="text/javascript" src="js/respond.min.js"></script>
总是在 js 脚本之前链接样式表或编写内联 CSS!
这篇关于Respond.JS 在 IE 8 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!