【问题标题】:Menu and submenus not showing on Internet ExplorerInternet Explorer 上未显示菜单和子菜单
【发布时间】:2014-03-10 23:40:56
【问题描述】:

我正在制作一个如下所示的菜单:

<nav>
<ul>
    <li><a href="index.php">Home</a></li>

    <li><a href="#">Expenses</a>
        <ul>
            <li><a href="view.php">View My Expenses</a></li>    
            <li><a href="employeeExpense.php">View Expenses</a></li>    

            <li> <a href="#">View Deconts </a>
                <ul>
                    <li><a href="viewAllDecont.php">Single Deconts</a></li>                                 
                    <li><a href="viewDecontsForAll.php">View All Deconts</a></li>
                </ul>
            </li>   
            <li> <a href="#">Add Expenses </a>
                <ul>
                    <li><a href="soccer.php">Soccer/Tennis Expenses</a></li>
                    <li><a href="gym.php">Gym Expenses</a></li>
                    <li><a href="coffeeTea.php">Coffee/Tea Expense</a></li> 
                </ul>
            </li>
    </li>               
</ul>

它在 chrome 和 firefox 上完美运行,在 IE 上无法运行。

导航 CSS 看起来像这样:

nav {   
text-align: center;
}

nav ul ul {
    display: none;  
    }

nav ul li:hover > ul {
    display: block;
    }

nav ul {
    background: #efefef; 
    background: linear-gradient(top, #efefef 0%, #bbbbbb 100%);  
    background: -moz-linear-gradient(top, #efefef 0%, #bbbbbb 100%); 
    background: -webkit-linear-gradient(top, #efefef 0%,#bbbbbb 100%); 
    box-shadow: 0px 0px 9px rgba(0,0,0,0.15);
    padding: 0 20px;
    border-radius: 10px;  
    list-style: none;
    position: relative;
    display: inline-table;
    z-index: 9999;

}
nav ul:after {
    content: ""; clear: both; display: block;
}

nav ul li {
    float: left;
}
    nav ul li:hover {
        background: #4b545f;
        background: linear-gradient(top, #4f5964 0%, #5f6975 40%);
        background: -moz-linear-gradient(top, #4f5964 0%, #5f6975 40%);
        background: -webkit-linear-gradient(top, #4f5964 0%,#5f6975 40%);
    }
        nav ul li:hover a {
            color: #fff;
        }

    nav ul li a {
        display: block; padding: 10px 40px;
        color: #757575; text-decoration: none;
    }


nav ul ul {
    background: #5f6975; border-radius: 0px; padding: 0;
    position: absolute; top: 100%;
}
    nav ul ul li {
        float: none; 
        border-top: 1px solid #6b727c;
        border-bottom: 1px solid #575f6a; position: relative;
    }
        nav ul ul li a {
            padding: 15px 40px;
            color: #fff;
        }   
            nav ul ul li a:hover {
                background: #4b545f;
            }

nav ul ul ul {
    position: absolute; left: 100%; top:0;
}

我是否使用过时的功能?我知道 -moz- 标签适用于 Mozilla Firefox,而 -webkit- 适用于 Chrome,但它最初是有效的。我一定是更新了 IE 什么的。我使用的是 IE 9。

【问题讨论】:

  • 什么不起作用?梯度? IE9 不理解 CSS 渐变。
  • 不再需要使用-moz-linear-gradient,顺便说一句:Firefox 没有前缀。
  • 菜单显示为 Word 中的列表:*首页 *费用 - 我的费用 - 我的 Decont - 添加 Decont
  • 渐变也不起作用。关于如何在 IE9 中解决这个问题的任何想法?

标签: css html


【解决方案1】:

我注意到了两件事。

1.) 您的代码看起来不错,只是缺少结束标记。这可能是复制粘贴问题。

2.) IE8 和之前的版本不能使用 nav 标签。那么你确认你在IE9模式下运行了吗?在 IE 中打开开发人员工具以确保 (F12)。确保文档和浏览器模式均未处于兼容模式并设置为 IE9 或您当前的任何版本。

【讨论】:

  • 嗨 Anthony Mason,1) 标签不会像我尝试的那样粘贴到 stackoverflow 中。 2) 我正在运行 IE9。如何让它在 IE9 标准中工作?
  • 啊,对了,我设法将其更改为 IE9 标准。我第一次点击它时它没有刷新。我现在看到了好的一面。谢谢
  • 我在您最初的帖子中看到您使用的是 IE9,我只是询问您是否在标准设置下运行。默认情况下,在 Intranet IE 上,默认为破坏现代代码的兼容模式。检查工具 -> 兼容性视图设置。或者F12打开开发者工具,进入文档设置,确保上面的配置都设置好了。\
  • 我没有刷新页面来查看您的回复 :) 很高兴我能提供帮助
  • 做到了,效果很好。我只是没有第一次看到它。好点安东尼。我仍然不明白为什么他们会选择默认显示某些内容,例如在旧版本的浏览器中。这真的没有任何意义。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-11-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-06-20
  • 1970-01-01
相关资源
最近更新 更多