【问题标题】:respond.js not working IE8 - even on web serverrespond.js 无法在 IE8 上运行 - 即使在 Web 服务器上也是如此
【发布时间】:2014-06-15 15:59:20
【问题描述】:

我正在尝试使用 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;
    }
}

我正在使用的 respond.js 链接(本地版本;https://github.com/scottjehl/Respond/blob/master/dest/respond.min.js

【问题讨论】:

    标签: html css respond.js


    【解决方案1】:
    <script src="/js/respond.min.js"></script>
    

    应该是

    <script src="js/respond.min.js"></script>
    

    注意我已经删除了前面的“/”

    当我在 IE 8 中进行媒体查询时,我现在正在“挥拳”。

    感谢您的宝贵时间。我希望这有帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-23
      • 1970-01-01
      • 1970-01-01
      • 2012-11-10
      • 1970-01-01
      • 2015-11-11
      • 2019-06-08
      • 1970-01-01
      相关资源
      最近更新 更多