【问题标题】:Why isn't my CSS working in IE 8 and IE 7?为什么我的 CSS 不能在 IE 8 和 IE 7 中工作?
【发布时间】:2013-07-09 11:20:08
【问题描述】:

此 CSS 中的哪些内容在 IE8 和 IE7 中不起作用?

nav {
position: fixed;
top:60px;
left:30px;
color:black;
float:left;
}
nav div#button {
    width:205px;
    height:50px;
    text-align: center;
    padding-top:  5px;
    margin-bottom:10px; 
    font-size: 23px;
}
nav a {
    color: #000000;
    text-decoration: none;
}
nav div#button:active  {
    width:250px;
    height:65px;
}
nav div#button.home {
    background-color: #79b22c;
}
nav div#button.links {
    background-color: #3b50cc;
}
nav div#button.aanbod {
    background-color: #BA3BCC;
}
nav div#button.forum {
    background-color: #1CAEB2;
}
nav div#button.contact {
    background-color: #daa520;
}

它在 IE9 和 IE10 中运行良好。但 IE8 和 IE7 显示无样式文本。 我已经用浏览器堆栈进行了测试。 谁能帮帮我?

【问题讨论】:

  • nav div#button 引起了一些担忧。在您的标记中,有多少个元素有 id="button"
  • 5 个带有 'id="button"' 的元素
  • ID 对于整个 <html> 文档中的单个元素应该是唯一的。您不应拥有超过 1 个id="button"。如果您需要在多个元素上重用,请改用 class 名称 -- class="button"class="button home"
  • nav 元素 isn't supported.

标签: css internet-explorer internet-explorer-8 cross-browser internet-explorer-7


【解决方案1】:

<nav> 和其他 HTML5 元素是在 IE 7 和 IE 8 发布之后定义的,因此浏览器不知道如何处理它们。

但是,可以指示他们处理它们。而且,html5shiv 可以提供帮助:

在任何样式表之后的条件注释中包含<head> 顶部的 HTML5 shiv。

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

【讨论】:

    【解决方案2】:

    尝试使用:

    <!DOCTYPE html>
    

    你也不需要:

    div#menu你需要#menu

    在代码的顶部

    【讨论】:

    • 我可以看看你的页面是什么样子的吗?它应该是什么样子
    【解决方案3】:

    删除颜色,只使用背景

    【讨论】:

      【解决方案4】:

      位置:固定在ie7中不起作用。在 css 中使用应该使用 expression() 并定位绝对值。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-10-29
        • 1970-01-01
        • 1970-01-01
        • 2015-03-02
        • 1970-01-01
        • 2013-02-16
        • 1970-01-01
        • 2011-06-24
        相关资源
        最近更新 更多