html下拉菜单在Firefox中不起作用,并且在旧版本的IE中一切都是错误的

html drop down menus not working in firefox and everything is wrong in older versions of IE

本文关键字:IE 错误 版本 Firefox 下拉菜单 不起作用 html      更新时间:2023-09-26

大家晚上好,我在火狐和IE中的下拉菜单遇到问题。

错误地开发了这个页面并在chrome上测试了所有内容,但是当一个朋友为我检查它时,他使用了Firefox并说他无法使用我的导航。有人可以指出我正确的方向吗谢谢。

如果有人能指出我正确的方向,让我的页面在IE上看起来不错,那就太好了

这是代码

<nav>
    <ul>
    <li><a href="#">Home</a></li>
    <li><a href="#"html">Register/login</a>
        <ul>
            <li><a href="register.php">Register</a></li>
            <li><a href="login.php">Login</a></li>
            <li><a href="#">Forgot Password</a>
                <ul>
                    <li><a href="#">Email Password</a></li>
                    <li><a href="#">Answer Security Questions</a></li>
                </ul>
            </li>
        </ul>
    </li>
    <li><a href="#">Contact Us</a>
        <ul>
            <li><a href="#">Email</a></li>
            <li><a href="#">Forum</a></li>
        </ul>
    </li>
    <li><a href="#">Contact Us</a>
        <ul>
            <li><a href="#">Email</a></li>
            <li><a href="#">Forum</a></li>
        </ul>
    </li>
    <li><a href="#">Contact Us</a>
        <ul>
            <li><a href="#">Email</a></li>
            <li><a href="#">Forum</a></li>
        </ul>
    </li>
    <li><a href="#">Contact Us</a>
        <ul>
            <li><a href="#">Email</a></li>
            <li><a href="#">Forum</a></li>
        </ul>
    </li>
</ul>
</nav>        

这是 CSS

nav {
    height:80px;
    width:1024px;
    }
ul {
    padding:0;
    margin:0;
    list-style:none;
    }
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 75px;
    border-radius: 10px;  
    list-style: none;
    position: relative;
    display: inline-table;
    z-index:100;
    }
nav ul:after {
    content: ""; clear: both; display: block;
    }
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: 25px 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;
    }
li ul {
    display: none;
    position: absolute; 
    top: 1em;
    left: 0;
    }
li > ul {
    top: auto;
    left: auto;
    }
li:hover ul, li.over ul{ display: block; }
#article{
    height:500px;
    width:1024px;
    background:#FFFFFF;
    }
#article>h1 {
    text-align:center;
    }
#legaljibjab {
    height:30px;
    width:1024px;
    border:black solid thin;
    background:#FFFFFF;
    }

较旧的浏览器不支持HTML5的新样式,某些事情可能会因为对html的较旧支持而出现故障,请尝试IE 10或Chrome,然后看看会发生什么。

您的 html 和 css 看起来正确,但要确保下载更新的浏览器。还要尝试取出<nav>元素。

可能是此行的无效 html?

<a href="#"html">Register/login</a>

我看到您的第二个<li>标签中有一个随机的html标签,这可能没有帮助。通过 html 验证器运行您的代码将为您创造奇迹。快速的谷歌搜索将为您提供许多不同的选择。

<nav> 标记是 html5 标记,IE8 及更早版本不支持该标记。我猜你的朋友可能使用的是旧版本的IE。在开发跨浏览器兼容性时,您需要记住,某些标签和技术在兼容性方面有所不同。有许多网站可以用来检查这一点。在学校,我经常使用——Caniuse.com

至于火狐不工作,我真的不能说。Firefox 与 <nav> 标签兼容,因此应该可以正常工作。您在浏览器的错误控制台中收到任何错误吗?