我正在使用 twitter bootstrap 实现一个响应式网站,但在 iexplorer 8 及以下版本上无法使用媒体查询。
我为 try respond.js 创建了一个简单的示例,但媒体查询在 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>
如果您在跨域设置方面遇到问题,请确保 response-proxy.html 没有附加查询字符串。
注意:非常感谢@doctyper 对跨域代理的贡献!
关于internet-explorer-8 - Respond.js 与 ie8 及以下的 twitter bootstrap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17523921/