1
我有一個CSS下拉菜單的問題。 你能幫我嗎?CSS水平下拉菜單
HTML:
<div id="menucontainer" align="center">
<div id="menubar" align="center">
<ul class="mainnav">
<li><a href="index.html">Home</a></li>
<li><a href="courses.html">Courses</a>
<ul class="submenu">
<ul class="column">
<li><a href="business.html">Business</a></li>
<li><a href="acca.html">• ACCA</a></li>
<li><a href="cat.html">• Certified Accounting Technician</a></li>
</ul>
<ul class="column">
<li><a href="english.html">English</a></li>
<li><a href="generalenglish.html">• General English</a></li>
<li><a href="camexenglish.html">• Cambridge Exam English</a></li>
</ul>
<ul class="column">
<li><a href="computing.html">Computing</a></li>
</ul>
</ul>
</li>
<li><a href="facilities.html">Facilities</a>
<ul class="submenu">
<li><a href="studyarea.html">Study Area</a></li>
<li><a href="itlab.html">IT Lab</a></li>
</ul>
</li>
<li><a href="services.html">Services</a>
<ul class="submenu">
<li><a href="airportpickup.html">Airport Pickup</a></li>
<li><a href="firstday.html">First Day Orientation</a></li>
</ul>
</li>
<li><a href="international.html">International</a>
<ul class="submenu">
<li><a href="aboutuk.html">About UK</a></li>
<li><a href="aboutlondon.html">About London</a></li>
</ul>
</li>
<li><a href="admissions.html">Admissions</a>
<ul class="submenu">
<li><a href="entryreq.html">Entry Requirements</a></li>
<li><a href="howtoapply.html">How to Apply</a></li>
</ul>
</li>
<li><a href="aboutus.html">About us</a>
<ul class="submenu">
<li><a href="messagefrom.html">Message from the Principal</a></li>
<li><a href="whychoose.html">Why Choose</a></li>
</ul>
</li>
<li><a href="contactus.html">Contact us</a>
<ul class="submenu">
<li><a href="byemail.html">By Email</a></li>
<li><a href="byphoneorfax.html">By Phone or Fax</a></li>
</ul>
</li>
</ul>
</div>
</div>
CSS
/* 2nd container */
#menucontainer { width:100%; height:54px; background-color:#872e26; }
#menubar { width:950px; height:54px; }
#headerx { width:100%; height:5px; background:#872e26; background-image:url(../images/footerx.png); background-position:center; background-repeat:no-repeat; }
/* 2nd container end */
/* drop menu */
.mainnav { list-style-type:none; padding:0; margin:0; text-align:center; }
.mainnav li { float:left; width:118.75px; }
.mainnav a { text-decoration:none; color:#fff; display:block; line-height:54px; }
.mainnav a:hover { background-color:#e3c153; color:#872e26; }
.submenu { display:none; list-style-type:none; padding:0; margin:0; background-color:#872e26; position:absolute; float:none; font-size:10px; }
li:hover .submenu { display:block; }
.column { list-style-type:none; text-align:center; }
/* drop menu end*/
- 我想,從下拉列表中的元素是一個在另一個之上,而不是像他們現在,一個緊挨着另一個。
- 此外,子菜單繼承導航的大小。我只能爲子菜單定義較少的行高嗎?
嘗試了一切,我似乎沒有找到過錯。
還有一件事,如果你看** **課程**,我怎樣才能創建3列,如float:left,out of ** Business,English and Computing **。所以這三者中的每一個都在單獨的列上,所以它們不會延伸太多而不能脫離屏幕?謝謝。 – Daniel
@Daniel您將不得不修改HTML結構。你希望他們能延伸出哪個「李」? –
所以我想安排在COURSES下的子菜單安排在3列,商業,英語和計算機。當然,每個人都有自己的「李」。希望你能理解我。 – Daniel