
[英]Media queries not working in IE8 - even with respond.js work-around
[英]respond.js not working IE8 - even on web server
我正在尝试使用react.js在IE8中使用/模拟媒体查询
我将所有的附加代码设置为在IIS(仅是简单且简单的静态站点)的localhost下运行。 一切都可以在Chrome,FF,Safari上运行,但不能在IE上运行(我正在使用版本8)
我是前端开发的新手,似乎无法弄清楚我做错了什么。 请有人可以看看并给我指点吗?
感谢您的时间,
巴里
HTML文件;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Media Query Test</title>
<link rel="stylesheet" type="text/css" href="css.css" />
</head>
<body>
<div class="wrapper one">This box will turn to pink if the viewing area is less than 600px</div>
<div class="wrapper two">This box will turn to orange if the viewing area is greater than 900px</div>
<div class="wrapper three">This box will turn to blue if the viewing area is between 600px and 900px</div>
<div class="wrapper iphone">This box will only apply to devices with max-device-width: 480px (ie. iPhone)</div>
<p class="viewing-area">
<strong>Your current viewing area is:</strong>
<span class="lt600">less than 600px</span>
<span class="bt600-900">between 600 - 900px</span>
<span class="gt900">greater than 900px</span>
</p>
<script src="/js/respond.min.js"></script>
</body>
</html>
CSS文件;
.wrapper {
border: solid 1px #666;
padding: 5px 10px;
margin: 40px;
}
.viewing-area span {
color: #666;
display: none;
}
/* max-width */
@media screen and (max-width: 600px) {
.one {
background: #F9C;
}
span.lt600 {
display: inline-block;
}
}
/* min-width */
@media screen and (min-width: 900px) {
.two {
background: #F90;
}
span.gt900 {
display: inline-block;
}
}
/* min-width & max-width */
@media screen and (min-width: 600px) and (max-width: 900px) {
.three {
background: #9CF;
}
span.bt600-900 {
display: inline-block;
}
}
/* max device width */
@media screen and (max-device-width: 480px) {
.iphone {
background: #ccc;
}
}
链接到我正在使用的response.js(本地版本; https://github.com/scottjehl/Respond/blob/master/dest/respond.min.js )
<script src="/js/respond.min.js"></script>
本来应该
<script src="js/respond.min.js"></script>
注意我删除了前面的“ /”
我现在正在“拳头抽气”,因为我在IE 8中有媒体查询。
谢谢你的时间。 我希望这有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.