internet-explorer-8 – 在ie8及以下使用twitter bootstrap的Respond.js

我正在实施一个带有Twitter bootstrap的响应式网站,但在iexplorer 8及以下版本中无法使用媒体查询.

我为try.js创建了一个简单的例子,但是mediaqueries继续不用于iexplorer 7-8,这里是html:

<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<title>Bootstrap 101 Template</title>
<meta name="Description" content="Web description here" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
<link href="./css/styles.css" rel="stylesheet">
<!--[if IE]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link rel="shortcut icon" href="./img/favicon.png">
</head>
<body>
<div class="container">
  <h1>Hello, world!</h1>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<script src="./js/respond.min.js"></script>
<script src="./js/scripts.js"></script>
</body>
</html>

这是style.css:

@media only screen and (max-width: 38.75em) {
body {
    background: green;
}
}

问候

最佳答案
https://github.com/scottjehl/Respond#cdnx-domain-setup

CDN / X域设置

Respond.js的工作原理是通过AJAX请求CSS的原始副本,因此如果您在CDN(或子域)上托管样式表,则需要上传代理页面以启用跨域通信.

有关演示,请参阅跨域/ example.html:

Upload cross-domain/respond-proxy.html to your external domain
Upload cross-domain/respond.proxy.gif to your origin domain
Reference the file(s) via <link /> element(s):

<!-- Respond.js proxy on external server -->
<link href="http://externalcdn.com/respond-proxy.html" id="respond-proxy" rel="respond-proxy" />

<!-- Respond.js redirect location on local server -->
<link href="/path/to/respond.proxy.gif" id="respond-redirect" rel="respond-redirect" />

<!-- Respond.js proxy script on local server -->
<script src="/path/to/respond.proxy.js"></script>

如果您遇到跨域设置问题,请确保respond-proxy.html没有附加查询字符串.

注意:非常感谢@doctyper在跨域代理中的贡献!

点赞