jq+css+html打造下拉導航選單例項
相信導航欄下拉選單是web開發最常見的一個item了.這裡就不做介紹了,直接上code。
Html部分
123
30- 4
756- 8
169 @Html.ActionLink("Test", "Test", new { area = "BMOManagement", controller = "Test" }) 10 @Html.ActionLink("Test", "Test", new { area = "BMOManagement", controller = "Test" }) 11 @Html.ActionLink("Test", "Test", new { area = "BMOManagement", controller = "Test" }) 12 @Html.ActionLink("Test", "Test", new { area = "BMOManagement", controller = "Test" }) 13 @Html.ActionLink("Test", "Test", new { area = "BMOManagement", controller = "Test" }) 1415- 17
2218 19 2021- 23
2924 25 26 2728
CSS部分
1 #sddm { 2 margin: 0 auto; 3 } 4 5 #sddm li { 6 margin: 0; 7 padding: 0; 8 list-style: none; 9 float: left; 10 font: bold 12px arial; 11 } 12 13 #sddm li a { 14 display: block; 15 margin: 0 1px 0 0; 16 padding: 4px 10px; 17 width: 60px; 18 color: #49AB6E; 19 text-align: center; 20 text-decoration: none; 21 } 22 23 #sddm li a:hover { 24 background: #49AB6E; 25 color: white; 26 } 27 28 #sddm div { 29 position: absolute; 30 visibility: hidden; 31 margin: 0; 32 padding: 0; 33 } 34 35 #sddm div a { 36 position: relative; 37 display: block; 38 margin: 0; 39 width: auto; 40 white-space: nowrap; 41 text-align: center; 42 text-decoration: none; 43 background: #49AB6E; 44 color: white; 45 font: 12px arial; 46 } 47 48 #sddm div a:hover { 49 background: #E5D6B8; 50 color: white; 51 }
JS部分
1 var timeout = 1; 2 var closetimer = 0; 3 var ddmenuitem = 0; 4 5 // close showed layer 6 function mclose() { 7 if (ddmenuitem) ddmenuitem.style.visibility = 'hidden'; 8 } 9 10 // cancel close timer 11 function mcancelclosetime() { 12 if (closetimer) { 13 window.clearTimeout(closetimer); 14 closetimer = null; 15 } 16 } 17 18 // close layer when click-out 19 document.onclick = mclose; 20 // --> 21 22 $(function () { 23 // open hidden layer 24 $(".a_nav_Menu").mouseover(function () { 25 var currentId = $(this).attr("id"); 26 27 // cancel close timer 28 mcancelclosetime(); 29 30 // close old layer 31 if (ddmenuitem) ddmenuitem.style.visibility = 'hidden'; 32 $("#" + currentId.replace("a_","")).width($("#" + currentId).parent().width() - 1); 33 $("#" + currentId).css({ "background": "#49AB6E", "color": "white" }); 34 35 // get new layer and show it 36 ddmenuitem = document.getElementById(currentId.replace("a_", "")); 37 ddmenuitem.style.visibility = 'visible'; 38 }); 39 40 // go close timer 41 $(".a_nav_Menu").mouseout(function () { 42 var currentId = $(this).attr("id"); 43 $("#" + currentId).css({ "background": "", "color": "#49AB6E" }); 44 45 closetimer = window.setTimeout(mclose, timeout); 46 }); 47 48 // go close timer 49 $(".div_nav_Menu").mouseout(function () { 50 var currentId = $(this).attr("id"); 51 $("#a_" + currentId).css({ "background": "", "color": "#49AB6E" }); 52 closetimer = window.setTimeout(mclose, timeout); 53 }); 54 55 $(".div_nav_Menu").mouseover(function () { 56 var currentId = $(this).attr("id"); 57 $("#a_" + currentId).css({ "background": "#49AB6E", "color": "white" }); 58 mcancelclosetime(); 59 }); 60 })
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/3016/viewspace-2800684/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- CSS導航欄及下拉選單CSS
- JavaScript slide下拉導航選單效果JavaScriptIDE
- 純css製作導航下拉選單CSS
- html 仿百度百科導航下拉選單功能例項程式碼介紹HTML
- jQuery 淡入淡出效果下拉導航選單jQuery
- CSS三級下拉導航選單詳解CSS
- JavaScript下拉摺疊導航選單講解JavaScript
- 滑鼠懸浮緩慢下拉導航選單
- CSS學習案例(14):下拉導航選單CSS
- CSS3立體導航選單程式碼例項CSSS3
- jQuery 緩衝效果二級導航下拉選單jQuery
- 二級下拉導航選單製作詳解
- bootstrap 選單導航選單nav li滑鼠移入hover下拉顯示boot
- CSS3動畫效果下拉導航選單效果CSSS3動畫
- [開發教程] 第32講:Bootstrap導航選單裡的下拉選單boot
- 純CSS打造淘寶導航選單欄CSS
- 點選平滑下拉展開摺疊樹形導航選單
- PbootCMS導航選單-導航選單的使用教程boot
- JavaScript實現HTML導航欄下拉選單[懸浮顯示]JavaScriptHTML
- jquery-滑鼠經過導航條,顯示二級下拉選單jQuery
- CSS垂直導航選單CSS
- JavaScript二級導航選單JavaScript
- CSS 動態導航選單CSS
- 導航選單(動畫)--- jQuery動畫jQuery
- JavaScript 三級導航選單JavaScript
- 設定select下拉選單的預設選中項
- 使用Vue實現下拉選單框批量新增選項Vue
- 純CSS的導航欄Tab切換例項CSS
- CSS多級導航選單效果CSS
- CSS垂直三級導航選單CSS
- Element-ui之導航選單UI
- 純原生javascript下拉框表單美化例項教程JavaScript
- jQuery三級導航選單詳解jQuery
- (四)選單導航及路由設定路由
- 固定在頂部的導航選單
- vue元件之路之menu導航選單Vue元件
- vue下拉選單Vue
- js物件導向封裝級聯下拉選單列表JS物件封裝