[英]why Respond.js and CSS3-mediaqueries.js both are not working in IE 7 & 8 for me?
I am building a HTML page with Twitter Bootstrap version 2.3.0. 我正在使用Twitter Bootstrap版本2.3.0构建HTML页面。 Since IE less than 9 does not support media queries I tried to use css3-mediaqueries.js.
由于小于9的IE不支持媒体查询,我尝试使用css3-mediaqueries.js。 The documentation says you need to just include the script after all css.
文档说你需要在所有css之后包含脚本。 I did that.
我做到了 Below is my page layout.
下面是我的页面布局。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Responsive page">
<meta name="author" content="Author name">
<title>Responsive page built on Twitter Bootstrap</title>
<link href="css/bootstrap.min.css" rel="stylesheet" type='text/css'>
<link href="css/bootstrap-responsive.min.css" rel="stylesheet" type='text/css'>
<link href="css/my-page.css" rel="stylesheet" type='text/css'>
<link href="css/my-page-responsive.css" rel="stylesheet" type='text/css'>
</head>
<body>
<div class="container">
<!-- My html goes here -->
</div>
<!--[if lt IE 9]>
<script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js">
</script> <![endif]-->
</body>
</html>
But still no luck. 但仍然没有运气。 I have not used any HTML5 element in my page.
我的页面中没有使用任何HTML5元素。 There is no error logged in javascript console.
在javascript控制台中没有记录错误。
Then I tried to use respond.js which throws the below exception. 然后我尝试使用respond.js抛出以下异常。
Unspecified error.
respond.js, line 309
What I am doing wrong here? 我在这做错了什么?
You need to still place the script in your <head>
, just after you stylesheets. 您还需要在样式表之后将脚本放在
<head>
。 Placing it at the bottom of the document causes the page to render before the script is loaded into memory. 将其放在文档的底部会导致页面在脚本加载到内存之前呈现。
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Responsive page">
<meta name="author" content="Author name">
<title>Responsive page built on Twitter Bootstrap</title>
<link href="css/bootstrap.min.css" rel="stylesheet" type='text/css'>
<link href="css/bootstrap-responsive.min.css" rel="stylesheet" type='text/css'>
<link href="css/my-page.css" rel="stylesheet" type='text/css'>
<link href="css/my-page-responsive.css" rel="stylesheet" type='text/css'>
<!--[if lt IE 9]>
<script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script>
<![endif]-->
</head>
Add respond.js before closing </body>
tag. 在关闭
</body>
标记之前添加respond.js。 Also, Please check your pages inside localhost otherwise it will throw Error. 此外,请检查localhost内的页面,否则将抛出错误。 I have used that way in many sites and it's working fine in IE7 and IE8.
我在很多站点都使用过这种方式,它在IE7和IE8中运行良好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.