0

Every1,

I am building a website for an organization that still only uses IE7. When creating this drop down menu on my laptop, the menu works without a problem. However, when trying it for the first time on a IE7 browser, it does not work.

<!doctype html>
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="./menu.css">
    <link rel="stylesheet" type="text/css" href="./styles.css">
    <title>Title</title>
</head>
<body>
    <header>
        <div id="logo">
            <img src="Crest.png">
        </div>
        <p id="name">Somename</p>
        <p id="motto">MyMotto</p>
    </header>

    <nav id="navigation">
        <ul>
            <li id="menu"><a href="#">Home</a></li>
            <li id="menu"><a href="#">Pubs</a>
                <ul id="subMenu">
                    <li><a href="#">Book 1</a></li>
                    <li><a href="#">Book 2</a></li>
                </ul>
            </li>
            <li id="menu"><a href="#">Links to Website</a>
                <ul id="subMenu">
                    <li><a href="#">Link 1</a></li>
                    <li><a href="#">Link 2</a></li>
                </ul>
            </li>
            <li id="menu"><a href="#">Departments</a></li>
            <li id="menu"><a href="#">References</a>
                <ul id="subMenu">
                    <li><a href="#">Ref 1</a></li>
                    <li><a href="#">Ref 2</a></li>
                </ul>
            </li>
            <li id="menu"><a href="#">Links</a>
                <ul id="subMenu">
                    <li><a href="#">More 1</a></li>
                    <li><a href="#">More 2</a></li>
                </ul>
            </li>
            <li id="menu"><a href="#">Forms</a>
                <ul id="subMenu">
                    <li><a href="#">Form 1</a></li>
                    <li><a href="#">Form 2</a></li>
                </ul>
            </li>
            <li id="menu"><a href="#">Orders</a></li>
            <li id="menu"><a href="#">Status</a></li>
        </ul>
    </nav>
</body>

Code for the menu.css

/* #navigation */
ul { 
    list-style:none;
    padding:0px;     
    margin:0px;
}

ul#subMenu a:hover { color: #FF0; font-weight: bold;}

#navigation { 
    margin-top: 20px;
    float: left;
}

#navigation ul, #navigation li {
    list-style: none; 
    padding: 0; 
    margin: 0; 
    display: inline;
    background-color: #30C;
    /* box-shadow: #111 3px 3px 4px; */
}

li#menu { box-shadow: #111 3px 3px 4px; }
ul#subMenu { box-shadow: #111 3px 3px 4px; }

#navigation ul li {
    float: left; 
    position: relative;
}

#navigation ul li a {
    display: block;
    padding: 3px 20px;
    margin: 1px;
    font-size: 12px;
    white-space: nowrap;
    color: #FFF;
    text-decoration: none;
    font-size: 16px;
}

#navigation ul ul {
    position: absolute;
    top: -99999px;  /* Remove them out of viewport */
    left: 0;        
    opacity: 0;     /* Hide sub level, we will use this in transition */
    -webkit-transition: opacity .4s ease-in-out;
    -moz-transition: opacity .4s ease-in-out;
    -o-transition: opacity .4s ease-in-out;
        transition: opacity .4s ease-in-out;
    z-index: 497;
    background: #30C;
    padding: 2px;
    border: 1px solid #444;
    border-top: none;
    box-shadow: #111 0 3px 4px;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
}

#navigation ul ul ul {
    position: absolute;
    top: -99999px;
    left: 100%;
    border-radius: 6px;
    border: 1px solid #444;
    background-color: #FFF;
}

#navigation ul li:hover>ul {
    opacity: 1;
    position: absolute;
    top: 99%;
    left: 0;
}

#navigation ul ul li:hover>ul {
    opacity: 1;
    position: absolute;
    top: 0%;
    left: 100%;
}

Code for the styles.css

body {
    width: 900px;
    margin: 0 auto;
    padding: 0;
    background-color: #006;
}

@font-face {
    font-family: Cowboys;
    src: url('Bleeding_Cowboys.ttf');
}

#logo {
    margin-top: 20px;
    padding: 0;
    float: left;
}

#name {
    float: left;
    font-size: 85px;
    margin: 0;
    margin-top: 20px;
    padding: 0;
    color: #FC0;
    font-family: Cowboys;
    position: relative;
    left: 40px;
}

#motto {
    float: left;
    font-size: 25px;
    margin: 0;
    padding: 0;
    position: relative;
    left: -460px;
    top: 160px;
    color: #FC0;
    font-family: Cowboys;
    font-style: italic;
}

The above code on IE7 does not even display the properties of a horizontal menu, instead it show it as vertical menu displaying all sub-menus and the font-face above also does not work.

What am I doing wrong?

Thanks.

4

3 回答 3

1

其他人指出<nav>IE7 不支持该标签。然而,问题远不止于此。IE7 不支持 HTML5 并且您的页面完全是 HTML5 - Doctype 不合适,不支持 header 标签,不支持 nav 标签。

您可以包含一些 javascript 库,以帮助推动旧版浏览器理解 HTML5。

此外,一些预先构建的框架,例如HTML5 Boilerplate也可能有助于支持旧版浏览器。

如果您主要为 IE7 构建,您可能希望坚持使用 xHTML 或 HTML4 和 CSS2。

于 2013-03-12T07:11:19.547 回答
0

ie7 不知道是什么nav....你应该使用 html5shiv.js 将其包含在文档中,然后添加nav{display:block}初学者

于 2013-03-12T03:28:42.450 回答
0

nav 不适用于 ie7 及以下使用

<!DOCTYPE html> 

在标题区域的顶部

于 2013-03-12T05:06:59.673 回答