internet-explorer-8 - Respond.js 与 ie8 及以下的 twitter bootstrap

标签 internet-explorer-8 internet-explorer-7 respond.js

我正在使用 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/

相关文章:

jquery - 在 Accordion 下方的页面上 float div

javascript - Jquery 选择器,我应该指定 html 标签的类型吗?

internet-explorer - Web 开发人员是否应该升级到 Internet Explorer 8?

css - Respond.js 跨域代理不工作

jquery - .load 在 IE8 中不工作 - 图片

html - 为什么内联 "background-image"样式在 Chrome 10 和 Internet Explorer 8 中不起作用?

javascript - IE7 不读取 CSS 和 JS 包

jquery - IE7 表现奇怪,悬停在 ul li 列表上没有任何中断

javascript - Bootstrap 3 + respond.js + IE8

javascript - 如何在 IE8 中使用响应 JS 应用 2 个媒体查询?