【问题标题】:Drop Down not even showing up in IE6Drop Down 甚至没有出现在 IE6 中
【发布时间】:2011-02-17 21:44:02
【问题描述】:

我在这里有一个下拉菜单,它不会在 IE6 中显示。该网站在所有其他浏览器中都能完美运行。我知道,在 IE6 上失眠似乎很愚蠢,但该网站是为可能仍在使用它的人群提供的。

这是 CSS:

html {
    height:100%;
}

body, p, a, ul, li, ol, h1, h2, h3, h4, h5, h6 {
    margin:0;
    padding:0;
}

body {
    behavior:url("csshover3.htc");
    font-size:14px;
    font-family:Arial, Helvetica, sans-serif;
    background-color:#d3d3d3;
    height:100%;
}

h1 {
    font-size:18px;
    color:#752eca;
    text-decoration:none;
}

h2 {
    font-size:14px;
    color:#909090;
    text-decoration:none!important;
}

p {
    text-indent:20px;
    color:#000;
}

p a {
    color:#000;
    text-decoration:underline;
}

p.foot {
    text-indent:0px;
}

p.link {
    font-size:18px;
    color:#30F;
    text-decoration:underline!important;
}

a {
    color:#4d2288;
    text-decoration:none;
    outline:none;
}

a:visited {
    color:#4d2288;
}

p a:hover {
    text-decoration:underline!important;
}

ul#nav {
    padding:5px;
    margin:0px auto;
    width:100%;
}

ul#nav li a {
    display:block;
    font-weight:bold;
    padding:2px 10px;
    background:#bacddb;
}

ul#nav li a:hover {
    background:#888;
    color:#fff;
}

li {
    list-style:none;
    float:left;
    position:relative;
    width:225px;
    text-align:center;
    margin:0px auto;
    margin-right:4px;
    border:1px solid #4d2288;
}

li ul {
    display:none;
    position:relative;
    width:auto;
    top:0;
    left:0;
    margin-left:-1px;
}

li>ul {
    top:auto;
    left:auto;
    border-top:none;
}

li:hover ul, li.over ul {
    display:block;
}

ul#nav li.current a {
    background:#b8ab28;
}

ul#nav li.current a:hover {
    background:#888;
}

img {
    margin:10px 0 5px;
}

*html img {
    margin:20px;
}

.coltextimg {
    position:relative;
    float:left;
    background-position:left bottom;
    padding:0px 20px 10px 0px;
    border:none;
}

#maincontent {
    width:940px;
    margin:0px auto;
    postition:absolute;
}

*html #maincontent {
    margin-left:42px;
}

#header {
    float:left;
    width:100%;
    height:auto!important;
    height:100%;
    min-height:100%;
    margin:0px auto;
    background-image:url(images/banner_test.jpg);
    background-repeat:no-repeat;
    border:2px solid #752eca;
    -webkit-border-top-left-radius:10px;
    -webkit-border-top-right-radius:10px;
    -moz-border-radius-topleft:10px;
    -moz-border-radius-topright:10px;
    border-top-left-radius:10px;
    border-top-right-radius:10px;
}

.colmask {
    position:relative;
    margin-top:160px;
    clear:both;
    float:left;
    width:100%;
    overflow:hidden;
}

.colright,
.colmid {
    float:left;
    width:100%;
    position:relative;
}

.col1,
.col2 {
    float:left;
    position:relative;
    padding:10px 0 1em 0;
    overflow:hidden;
}

.twocol {
    background:#fff;
}

.twocol .colmid {
    right:45%;
    background:#fff;
}

.twocol .col1 {
    width:51%;
    left:47%;
    text-align:justify;
    z-index:0;
}

.twocol .col2 {
    width:41%;
    left:51%;
    text-align:justify;
    z-index:0;
}

.twocol .colimg {
    border:2px solid #a0a0a0;
}

.twocol .colvid1 {
    width:360px;
    height:240px;
}

.twocol .colvid2 {
    width:360px;
    height:240px;
}

#footer {
    text-align:center;
    font-size:9px;
    padding:10px 0 1em 0;
    clear:both;
    width:100%;
    height:100%;
}

*html #footer {
    height:43px;
}

#footer p a {
    text-decoration:none;
}

#lyr_ddmenu {
    position:absolute;
    z-index:1;
    height:10px;
    top:120px;
    float:left;
    width:1000px;
    margin:0px auto;
    padding:5px;
}

#contact {
    position:absolute;
    float:right;
    font-size:10px;
}

A.Controls:link {
    color:#666666;
    text-decoration:none;
    font-weight:bold;
}

A.Controls:visited {
    color:#666666;
    text-decoration:none; 
    font-weight:bold;
}

A.Controls:active {
    color:#666666;
    text-decoration:none;
    font-weight:bold;
}

A.Controls:hover {
    color:#be0000;
    text-decoration:none;
    font-weight:bold;
}

这是我遇到特定问题的 html:

<div id="maincontent">
<div id="header">
    <div id="lyr_ddmenu">
        <ul id="nav">
            <li class="current"><href here...</a>
        <ul class="sub">
            <li><href here...</a></li>
            <li><href here...</a></li>
            <li><href here...</a></li>
            <li><href here...</a></li>
            <li><href here...</a></li>
        </ul></li>
            <li><href here...</a></li>
        <ul class="sub">
            <li><href here...</a></li>
            <li><href here...</a></li>
            <li><href here...</a></li>
            <li><href here...</a></li>
        </ul></li>
            <li><href here...</a></li>
            <li><href here...</a></li>
        <ul class="sub">
            <li><href here...</a></li>
        </ul></li>
        </ul>
</div>

谢谢!

【问题讨论】:

    标签: css internet-explorer-6 drop-down-menu


    【解决方案1】:

    1) 从body 中删除behavior:url("csshover3.htc");

    2) 将此添加到底部(更好地替换.htc

    * html li { scrollbar-face-color: expression(runtimeStyle.scrollbarFaceColor = '#fff', onmouseover = function() {this.className += ' hover'}, onmouseout = function() {this.className = this.className.replace(/ hover/g, '')} ); }
        li.hover ul { display:block; } /* (li:hover) */
    

    3) 应该可以工作。


    或尝试分开

    li:hover ul { display:block; }
    li.over ul { display:block; }
    

    你也可以使用jQuery来处理:hover

    jQuery(function($) {
        $("li").bind('mouseover mouseout',function(){$(this).toggleClass('hover')});
    });
    

    .hover课堂上玩耍:

    li.hover ul { _display: block; } /* Styles for IE6 */
    

    【讨论】:

    • 谢谢,干净多了,但仍然看不到 ie6 中的下拉菜单。这是堆栈顺序错误吗?正如我所说,其他所有浏览器在其他浏览器中看起来和工作都很好......
    • 嗯...仍然没有。真的考虑只是不关心,>8% 使用 IE6...
    【解决方案2】:

    IE6 不支持所有元素都使用:hover 伪类,只支持a 标签,因此以下规则不会在IE6 中应用:

    li:hover ul, li.over ul {
        display:block;
    }
    

    看起来您的菜单旨在使用 Javascript 来模拟 :hover,方法是使用 mouseover 函数将类 over 添加到 li 元素,因此您需要先发布任何 Javascript,然后才能发布诊断 IE6 中发生了什么。

    如果这可能有帮助,您可以使用 Whatever:hover 脚本在 IE6 中模拟此行为。

    【讨论】:

    • 感谢您的及时回复。 “如果这可能会有所帮助,您可以使用 What:hover 脚本来模拟 IE6 中的这种行为。”身体{行为:url(“csshover3.htc”);字体大小:14px;字体系列:Arial、Helvetica、sans-serif;背景颜色:#d3d3d3;高度:100%;我相信我在这里正确地使用了它,但也许没有。我将检查是否尝试手动将 :hover 应用于我的列表。您知道使用 *html hack 的方法吗?另外...下拉菜单没有 js...我已经删除了 .over 类,不知道为什么会这样!谢谢。
    • 哦,我的错,我什至没有看到你的body 课程。我的猜测是 .htc 文件的 url 或脚本的其他内容可能是错误的。请记住,您的 css 文件中的 url 是相对于 css 文件的。另外,我建议不要使用 *html 之类的 hack,而是使用条件 cmets 来包含仅适用于 IE6 的样式表和 hack。见这里:msdn.microsoft.com/en-us/library/ms537512%28VS.85%29.aspx
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-19
    • 1970-01-01
    • 2017-01-01
    • 2018-03-26
    • 2023-03-19
    • 1970-01-01
    相关资源
    最近更新 更多