html - 响应式设计在 IE7 和 IE8 等中不起作用

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

你好 friend ,请帮助我,我已经使用了所有方法,但响应式设计在 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;}

**

请告诉我我的 friend 们我错过了什么。

最佳答案

在您的 !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 浏览器提供移动 View ,而不使用 JS 作为默认浏览器。 @Jefferson-Ribeiro 的链接中推荐了这种做法。它会正常工作。

关于html - 响应式设计在 IE7 和 IE8 等中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25182928/

相关文章:

jquery - 不确定为什么 div 不会淡入?

html - 更改单个 li 元素的 css

html - 我可以使用媒体查询有效地创建一个单独的移动站点吗?

CSS 边框半径在盒子的所有侧面都没有 flex

javascript - 根据视口(viewport)高度为 x 图像行分配相同的高度

javascript - css 缩放在 ie11 中不起作用

javascript - 如何最好地计算 TextArea 中文本的字节数

html - 在 IE 9 中加载嵌入式 mp3 时文本字段失去焦点?

css - Internet Explorer 输入按钮 - 单击它似乎添加了阴影并使文本变灰

html - 移动版 chrome 顶部栏的颜色