2014-01-29 95 views
2

我已經創建了一個CSS和HTML導航菜單,適用於除IE6 - IE8以外的所有瀏覽器。我該如何做這項工作?我試圖使我的CSS和HTML儘可能小,以幫助兼容性,但無濟於事。下拉CSS和HTML導航菜單不工作在IE6 - IE8

CSS和HTML

ul ul { 
 
    display: none; 
 
} 
 
ul li:hover > ul { 
 

 
    display: block; 
 
} 
 
ul { 
 
    background-color: #99CCFF; 
 
    background-color: rgb(153, 204, 255); 
 
    list-style-type: none; 
 
    position: relative; 
 
    display: inline-table; 
 
    font-family: 'Julius Sans One', sans-serif; 
 
} 
 
ul:after { 
 
    content: ""; clear: both; display: block; 
 
} 
 
ul li { 
 
    float: left; 
 
    display:none; 
 
} 
 
ul li:hover { 
 
    background: #6699CC; 
 
} 
 
ul li:hover a { 
 
    color: #000000; 
 
} 
 
ul li a { 
 
    display: block; padding: 25px 40px; 
 
    color: #000000; text-decoration: none; 
 
} 
 
ul ul { 
 
    background: #99CCFF; padding: 0; 
 
    position: absolute; top: 100%; 
 
} 
 
ul ul li { 
 
    display:inline; 
 
    float: none; 
 
    border-top: 0px solid #6b727c; 
 
    border-bottom: 0px solid #575f6a; 
 
    position: relative; 
 
} 
 
ul ul li a { 
 
    padding: 15px 40px; 
 
    color: #000000; \t 
 
} \t 
 
ul ul li a:hover { 
 
    background: #6699CC; 
 
} 
 
ul ul ul { 
 
    position: absolute; left: 100%; top:0; 
 

 
}
<ul id="nav"> 
 
    <li><a href="#">Contact Us</a> 
 
    <ul> 
 
     <li><a href="address.html">Address</a></li> 
 
     <li><a href="rentals.html">Rentals</a></li> 
 
     <li><a href="phonenumbers.html">Phone Numbers</a></li> 
 
    </ul> 
 
    </li> 
 
    <li><a href="#">Mass</a> 
 
    <ul> 
 
     <li><a href="http://www.usccb.org/nab/today.shtml" target="_blank">Readings</a></li> 
 
     <li><a href="bulletins.html">Bulletins</a></li> 
 
     <li><a href="http://www.vatican.va/archive/ccc_css/archive/catechism/ccc_toc.htm" target="_blank">Catechism</a></li> 
 
     <li><a href="http://www.archindy.org/" target="_blank">Archdiocese of<br>Indiana</a></li> 
 
     <li><a href="confessions.html">Confession</a></li> 
 
     <li><a href="dailymass.html">Mass Schedule</a></li> 
 
    </ul> 
 
    </li> 
 
    <li><a href="#">Ministries</a> 
 
    <ul> 
 
     <li><a href="school.html">Pre-School</a></li> 
 
     <li><a href="daycare.html">Day Care</a></li> 
 
     <li><a href="ccd.html">CCD</a></li> 
 
     <li><a href="http://www.gandouministry.com/" target="_blank">Haiti<br>Ministry</a></li> 
 
    </ul> 
 
    </li> 
 
    <li><a href="#">Info</a> 
 
    <ul> 
 
     <li><a href="park.html">Walking<br>Park</a></li> 
 
     <li><a href="councils.html">Councils &<br>Committees</a></li> 
 
     <li><a href="cemetery.html">Cemetery Rules</a></li> 
 
     <li><a href="bulletins.html">Bulletins</a></li> 
 
     <li><a href="http://www.vatican.va/archive/ccc_css/archive/catechism/ccc_toc.htm" target="_blank">Catechism</a></li> 
 
    </ul> 
 
    <li><a href="#">Activities</a> 
 
    <ul> 
 
     <li><a href="laborday.html">Labor Day<br>Festival</a></li> 
 
     <li><a href="bingo.html">Bingo</a></li> 
 
     <li><a href="drawdon.html">Drawdown</a></li> 
 
     <li><a href="fund.html">MSGR Schmitz<br>Memorial Fund</a></li> 
 
    </ul> 
 
    </li> 
 
</ul>

+1

嗯,首先,'>'[*不*由IE6的支持(http://caniuse.com/css-sel2)我建議放棄對他們的支持。如果你真的關心IE用戶,不要做一個純粹的CSS下拉菜單。你需要JS。 –

+2

您提供的代碼甚至不能在任何瀏覽器中運行... [jsfiddle](http://jsfiddle.net/SinisterSystems/p7BG6/7/) –

回答

0

看起來你有太多的UL選擇在你的CSS規則前面。

<ul> 
    <li> 
     <ul> </ul> 
    </li> 
<ul> 

這是您的基本結構。嘗試從其中超過2個的css中刪除額外的ul

其次,我注意到你正在使用行內表規則。像這樣的規則往往與老版本的IE有關,所以請確保對這些類型的規則進行兼容性檢查。這裏還有一個SO張貼作爲參考,以這樣的:

display:inline-table