html - Internet Explorer 7 中的 CSS 下拉菜单爆炸

标签 html css internet-explorer drop-down-menu cross-browser

我正在创建一个带有下拉菜单的设计,并且一切都在现代浏览器(即 Firefox、Chrome、Opera、Safari 和 IE9)中运行良好。但是,由于使用IE7和IE8的访问者较多,我还需要使菜单与这些版本的Internet Explorer兼容。

这是下拉菜单( fiddle , pastebin ):

HTML

<ul class="menu_top">
    <li><a href="/" title="Home" class="selected">Home</a></li>
    <li><a href="/Help_Videos" title="Help Videos" class="haschildren">Help Videos</a><ul>
        <li><a href="/Child_Page" title="Child Page">Child Page</a></li>
        <li><a href="/Site_Map" title="Site Map" class="haschildren">Site Map</a><ul>
            <li><a href="/Galleries" title="Galleries">Galleries</a></li>
            <li><a href="/Missing" title="Missing">Missing</a></li></ul>
        </li></ul>
    </li>
    <li><a href="/About" title="About" class="haschildren">About</a><ul>
        <li><a href="/Contact" title="Contact">Contact</a></li></ul>
    </li>
</ul>

CSS

ul.menu_top {
    float:left;
    width:70%;
    margin: 8px 100px 0 0;
    border-radius:4px;
    background-color: #c4092a;
    list-style-type: none;
    z-index:+1;
}
ul.menu_top li {
    float: left;
    position: relative;
    margin: 4px 2em 4px 4px;
    padding: 0;
}
ul.menu_top li ul {
    visibility: hidden;
    position: absolute;
    top:100%;
    left:0;
    padding:0.5em;
    list-style-type: none;
    white-space:nowrap;
    background-color: #c4092a;
    border: 1px solid white;
    border-radius:4px;
    z-index:+1;
}
ul.menu_top li:hover > ul {
    visibility: visible;
    z-index: +2;
}
ul.menu_top li ul li {
    padding: 0;
    margin: 12px 4px;
    float:none;
    border:0;
    min-width:3em;
}
ul.menu_top li ul li ul {
    top:0;
    left:99%;
}
ul.menu_top a {
    background-color:#c4092a;
    color:white;
    text-decoration:none;
    padding:4px;
    font-size:18px
}
ul.menu_top a:hover,
ul.menu_top a.haschildren.childselected,
ul.menu_top a.selected {
    background-color:white;
    color:blue;
    text-decoration:none;
}
ul.menu_top li a.haschildren:after {
    content: "\00A0\00A0\25BC";
}
a {
    color:#0000aa;
    background-color:inherit;
}

IE7 和 IE8 中的屏幕截图

How it looks like in IE7+IE8

我已经在 IE Developer Tools 中测试了向后兼容性:

  • IE7: <ul>列表被替换,无法导航
  • IE8:只缺少圆 Angular (这是个小问题)

我尝试按照 this answer 中的建议修改样式,但没有成功。

那么,有人知道如何解决这些问题吗?

最佳答案

总的来说,您的问题是您使用的 CSS 比您需要支持的某些浏览器更先进。圆 Angular 和大多数伪元素在旧版浏览器中的支持参差不齐。

我注意到您的箭头在 IE7 中丢失,这是我的线索。 IE7 不支持伪类元素:after。这是一个有用的引用页面,用于检查某些 CSS 的浏览器支持 http://kimblim.dk/css-tests/selectors/ .

Quirksmode.org 是一个很好的兼容性资源。这是特定于 :after http://www.quirksmode.org/css/beforeafter.html 的页面

关于html - Internet Explorer 7 中的 CSS 下拉菜单爆炸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11618649/

相关文章:

html - html中颜色选择的效率。 RGB vs 十六进制 vs 名称

html - CSS - 如何水平对齐我的 div?

html - CSS float 框意外的 Angular 凹凸

Android 图像在设备旋转之前不会出现

html - IE 开始输入文本框时将屏幕居中

html - Flask 图标无法在 Google Chrome 上运行

IE11 中的 css 计算错误

css - 分组 Css 选择器(即子 OR 选择器)

internet-explorer - CSS 3 媒体查询支持 IE

javascript - 使用 CSS3 缩放属性时检测 IE 中的实际窗口大小