所以我有一個CSS下拉菜單在IE中顯示錯誤的問題。在其他瀏覽器中,它的工作方式應該如此。IE Css下拉菜單問題
<body>
<div id="container">
<header>
<div id="hlogo">
<a href="index.html">title</a>
</div>
<nav id="hmenu">
<ul>
<li>
<a href="menu1.html">menu1</a>
</li>
<li>
<a href ="menu2.html">menu2</a>
<div id="items" class="hiddenMenu">
<a href="submenu1.html">submenu1</a>
<a href="submenu2.html">submenu2</a>
<a href="submenu3.html">submenu3</a>
<a href="submenu4.html">submenu4</a>
</div>
</li>
<li>
<a href ="menu3.html">menu3</a>
</li>
<li>
<a href ="menu4.html">menu4</a>
</li>
</ul>
</nav>
</header>
<section id="container-body">
<div id="content">
</div>
</section>
</div>
所以這是我完整的HTML。它有一個由以下CSS提供的佈局。
/* layout styles */
*{margin:0;padding:0;font-family:Arial;}
header{overflow:hidden;}
body{background-color:#cc3333;}
a {display: inline-block;font-weight: bold;text-decoration:none;}
footer {
display:block;
position:relative;
width:100%;
}
footer > #disclamer {
margin-left: auto;
margin-right: auto;
width: 200px;
padding-bottom:5px;
font-size:small;
font-weight: bold;
}
#container{
background-color:#ffffff;
margin:auto;
min-width:756px;
width:60%;
overflow:hidden;
border:solid 2px #666666;
margin-top:10px;
margin-bottom:10px;
box-shadow:0 1px 3px rgba(0,0,0,0.6);
}
#hlogo {float:left;height:105px;width:181px;padding:10px;}
#hlogo a{background-position: 0px 0px;float:left;display:inline;height:105px;text-indent:-999999em;width:181px;}
#hlogo a{background-image:url('../images/logo.png');background-repeat:no-repeat;overflow:hidden;}
#hmenu{margin-top:45px;padding:10px;}
nav {
list-style:none;
display:inline;
float:right;
}
nav ul{
list-style: none;
text-align:center;
background-color:#666666;
float:left;
}
nav ul li {
width:128px;
float:left;
display:inline-block;
}
nav ul li:hover{
background-color:#cc3333;
cursor:pointer;
}
nav ul li a {
color:#ffffff;
padding:10px;
}
nav ul {
background: #222 url('../images/overlay.png') repeat-x;
color: #fff;
text-shadow: 0 -1px 1px rgba(0,0,0,0.25);
cursor: pointer
}
section {margin:10px;}
#container > header {display:block;}
#container-body {
background-color:#ececec;
height:600px;
display:block;
overflow:auto;
}
#container-body > #content {
margin: 10px;
height:95%;
position:relative;
}
.hiddenMenu
{
position:absolute;
z-index: 150;
background: #222 url('../images/overlay.png') repeat-x;
color: #fff;
text-shadow: 0 -1px 1px rgba(0,0,0,0.25);
cursor: pointer;
width: inherit;
}
.hiddenMenu > a
{
position:relative;
text-align: left;
clear:both;
font-size:0.75em;
}
nav li .hiddenMenu > a
{
display:none;
}
/*nav li:hover .hiddenMenu > a
{
display:block;
}*/
nav li .hiddenMenu > a:hover
{
background-color:#cc3333;
cursor:pointer;
border: 1px black solid;
}
這是完整的CSS。
這是我使用的CSS。現在在Firefox中,它可以正常工作。菜單顯示當我懸停menu2項目。在IE上它顯示第一個子菜單項(子菜單1),然後它被清除,所以我甚至不能點擊它。
我看不出我做錯了什麼,所以如果你能幫助我,我將不勝感激。謝謝!
編輯:添加代碼。
頭標記有一個overflow:hidden屬性;如果我將其設置爲可見,則會顯示完整菜單,但會完全混亂我的佈局。有沒有辦法繞過它,或者我做錯了什麼?
另外,我有一個jquery腳本來將菜單上的顯示設置爲none/block,但在IE中,如果我將鼠標懸停在子菜單項上,菜單仍將隱藏。爲什麼會發生?
李:當我將鼠標懸停在它顯示菜單項懸停不工作可能 – 2011-01-20 23:14:39
,所以我認爲這是工作 – Alka 2011-01-20 23:27:16