【问题标题】:Responsive Design It's not working in IE7 and IE8 etc响应式设计在 IE7 和 IE8 等中不起作用
【发布时间】:2014-09-30 17:15:41
【问题描述】:

你好朋友请帮助我,我已经使用了各种方式,但响应式设计在 IE 中不起作用。我已经使用了一切。我也使用过 css-mediaqueries.js。没用,请帮帮我

这里我给你我的示例 html 页面:

<!DOCTYPE html>
<!--[if IE 7 ]><html class="ie7" lang="en"><![endif]-->
<!--[if IE 8 ]><html class="ie8" lang="en"><![endif]-->
<!--[if IE 9 ]><html class="ie9" lang="en"><![endif]-->
<!--[if !IE]><!--> <html> <!--<![endif]-->

<head>
<!-- Meta -->
<meta charset="utf-8">
<meta name="keywords" content="" />
<meta name="description" content="">
<meta name="author" content="">
<title>Ads View Page</title>
<!-- Mobile Meta -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--[if IE]> 
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<![endif]-->
<!-- css -->
<link rel="stylesheet" href="inc-media/bsm_style.css">
<link rel="stylesheet" href="inc-media/responsive.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

 <!--[if lt IE 9]>
<script src="inc-media/html5shiv.js"></script>
<script src="inc-media/respond.js"></script>

<![endif]-->

</head>

<body>
<header></header>
</body>
</html>

这是我的响应式和主要 Css 响应式 CSS

@charset "utf-8";
/* CSS Document */
@media screen and (min-width: 768px) and (max-width: 979px) {
    header{ background:#FF0000!important;
    }
}
@media screen and (max-width: 767px) {
        header{ background:#069!important;}
}
@media screen and (max-width: 480px) {
    header{ background:#36F!important;}
}

主CSS

/*  Reset Styling
----------------------------------------------------------------------*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center, dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
}
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section, img {
    display: block;
}
body {
    line-height: 1;
}
ol, ul {
    list-style: none;
}
blockquote, q {
    quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
    content: '';
    content: none;
}
table {
    border-collapse: collapse;
    border-spacing: 0;
}
* {
    outline: none;
    padding: 0px;
    margin: 0px
}
body{
    background:#999;}
header{ width:100%; background:#fff; height:150px; border-bottom:1px soild #333; margin:0px; padding:0px;}

**

请告诉我的朋友们我之间缺少什么。

【问题讨论】:

  • 你确定respond.js的路径是正确的吗?您是在本地测试还是在现场测试?有些脚本可能无法在本地运行,但它们可以在实时站点上运行。
  • 我已经检查了 respond.js 它是正确的..因为即使我已经再次下载了它......而且我还在线检查了该脚本......仍然无法正常工作..
  • respond.js 不支持所有类型的媒体查询,我会检查第一个是否是问题。双“和”逻辑可能超出插件的支持范围。

标签: html css internet-explorer responsive-design media-queries


【解决方案1】:

在您的 !important 和实际值之间添加空格。

@media screen and (min-width: 768px) and (max-width: 979px) {
    header{
        background:#FF0000 !important;
    }
}
@media screen and (max-width: 767px) {
    header{
        background:#069 !important;
    }
}
@media screen and (max-width: 480px) {
    header{
        background:#36F !important;
    }
}

另外,如果您以更好的方式进行编码 - “移动优先” - 更好的做法是为您的 IE7 和 IE8 浏览器提供移动视图,而不使用 JS 作为默认值。 @Jefferson-Ribeiro 的链接中推荐了这种做法。它会起作用的。

【讨论】:

    【解决方案2】:

    前面的答案应该可以解决问题,但这里更重要的问题是:为什么要它在 IE7 和 IE8 上响应?

    响应式网站的唯一目的是用于手机和平板电脑。

    并且第一个移动 Windows 设备以 IE10 开头,这意味着 IE7-9 不能在任何手机/平板电脑上使用。

    换句话说,让网站在 IE7 和 8 上响应式根本没有必要。

    【讨论】:

    • 唯一的目的是制作一个可以在任何设备上运行的网站。手机和平板电脑只是您应该构建响应式的最明显示例。建立一个体面的流体响应网站,您仍然可以为 ie8 用户提供良好的体验。只要确保它值得花时间。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-26
    • 2011-09-28
    • 2012-10-08
    • 1970-01-01
    • 1970-01-01
    • 2013-02-11
    • 1970-01-01
    相关资源
    最近更新 更多