我正在尝试使用respond.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)
答案 0 :(得分:0)
<script src="/js/respond.min.js"></script>
应该是
<script src="js/respond.min.js"></script>
注意我已删除了前面的&#34; /&#34;
我现在&#34;拳头抽水&#34;我在IE 8中有媒体查询。
感谢您的时间。我希望这有帮助!