CSS 實現樣式下拉式功能表

來源:互聯網
上載者:User

標籤:

下拉式功能表的實現

指令碼:

 1 <script type="text/javascript"> 2         function ShowSub(li) { 3             var subMenu = li.getElementsByTagName("ul")[0]; ; 4             subMenu.style.display = "block"; 5         } 6         function HideSub(li) { 7             var subMenu = li.getElementsByTagName("ul")[0]; 8             subMenu.style.display = "none"; 9         }10     </script>
View Code

CSS代碼:

1 *{ margin:0px; padding:0px;}2  #menu{ background-color:#eee; width:600px; height:40px; margin:0 auto;}3  ul{ list-style:none;}4  ul li{ line-height:40px; text-align:center; position:relative; float:left; }5  a{ text-decoration:none; color:#000; display:block; width:90px;}6  a:hover{ color:#FFF; background-color:#666;}7  ul li ul li{ float:none;margin-top:2px; background-color:#eee; } 8  ul li ul{width:90px; position:absolute;display:none; }9  ul li:hover ul{display:block;}
View Code

頁面HTML代碼:

 1 <div id="menu"> 2 <ul> 3   <li><a href="#">首頁</a></li> 4   <li><a href="#">課程大廳</a> 5     <ul> 6       <li><a href="#">Javascript</a></li> 7       <li><a href="#">jQuery</a></li> 8     </ul> 9   </li>10   <li><a href="#">學習中心</a>11     <ul>12       <li><a href="#">視頻學習</a></li>13       <li><a href="#">案例學習</a></li>14       <li><a href="#">交流平台</a></li>15     </ul>16   </li>17   <li><a href="#">經典案例</a></li>18   <li><a href="#">關於我們</a></li>19   <li><a href="#">聯絡我們</a></li>20 </ul>21 </div> 
View Code

代碼效果:

 

CSS 實現樣式下拉式功能表

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.