respond.js not working IE8 - even on web server

无人久伴 提交于 2019-12-11 23:18:56

问题


I'm trying to use/ mock media queries in IE8 using respond.js

I have the attached code all set-up to run under localhost in IIS (just a plain and simple static site). Everything works on Chrome, FF, Safari but not IE (I'm using version 8)

I'm new to front end development and I cannot seem to work out what it is I am doing wrong. Please can somebody take a look and give me any pointers?

Thank you for your time,

Barry.

HTML File;

<!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 File;

.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;
    }
}

Link to respond.js I am using (local version of; https://github.com/scottjehl/Respond/blob/master/dest/respond.min.js)


回答1:


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

Should have been

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

Note I have removed the preceeding "/"

I am now "fist pumping" the air as I have media queries in IE 8.

Thanks for your time. I hope this helps!



来源:https://stackoverflow.com/questions/23369324/respond-js-not-working-ie8-even-on-web-server

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