本文實例講述了js實現的後台左側管理菜單代碼。分享給大家供大家參考。具體如下:
這是一個完美的後台左側管理菜單,從樣式來說,貌似出自專業人士之手,風格清新,操作實用,用在WEB管理系統中或用在網站後台管理中,最恰當不過了。
運行效果截圖如下:
在線演示地址如下:
http://demo.jb51.net/js/2015/js-left-main-menu-style-codes/
具體代碼如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML>後台左側菜單<HEAD> <META http-equiv=Content-Type content="text/html; charset=gb2312"> <style> BODY { MARGIN: 0px } P { MARGIN: 0px } BODY { COLOR: #000; BACKGROUND-COLOR: #fff } BODY { FONT-SIZE: 12px; LINE-HEIGHT: 150%; FONT-FAMILY: "Verdana", "Arial", "Helvetica", "sans-serif" } TABLE { FONT-SIZE: 12px; LINE-HEIGHT: 150%; FONT-FAMILY: "Verdana", "Arial", "Helvetica", "sans-serif" } INPUT { FONT-SIZE: 12px; FONT-FAMILY: "Verdana", "Arial", "Helvetica", "sans-serif" } SELECT { FONT-SIZE: 12px; FONT-FAMILY: "Verdana", "Arial", "Helvetica", "sans-serif" } TEXTAREA { FONT-SIZE: 12px; FONT-FAMILY: "Verdana", "Arial", "Helvetica", "sans-serif" } A:link { COLOR: #036; TEXT-DECORATION: none } A:visited { COLOR: #036; TEXT-DECORATION: none } A:hover { COLOR: #f60; TEXT-DECORATION: underline } A.menuChild:link { COLOR: #036; TEXT-DECORATION: none } A.menuChild:visited { COLOR: #036; TEXT-DECORATION: none } A.menuChild:hover { COLOR: #f60; TEXT-DECORATION: underline } A.menuParent:link { COLOR: #000; TEXT-DECORATION: none } A.menuParent:visited { COLOR: #000; TEXT-DECORATION: none } A.menuParent:hover { COLOR: #f60; TEXT-DECORATION: none } TABLE.position { WIDTH: 100% } TR.position { HEIGHT: 25px; BACKGROUND-COLOR: #f4f7fc } TD.position { BORDER-RIGHT: #adceff 1px solid; PADDING-LEFT: 20px; BORDER-BOTTOM: #adceff 1px solid } TABLE.listTable { WIDTH: 98%; BACKGROUND-COLOR: #b1ceee } TR.listHeaderTr { FONT-WEIGHT: bold; HEIGHT: 25px; BACKGROUND-COLOR: #ebf4fd; TEXT-ALIGN: center } TR.listTr { HEIGHT: 25px; BACKGROUND-COLOR: #fff; TEXT-ALIGN: center } TR.listAlternatingTr { HEIGHT: 25px; BACKGROUND-COLOR: #fffdf0; TEXT-ALIGN: center } TR.listFooterTr { HEIGHT: 30px; BACKGROUND-COLOR: #ebf4fd; TEXT-ALIGN: center } TABLE.editTable { WIDTH: 98%; BACKGROUND-COLOR: #b1ceee } TR.editHeaderTr { HEIGHT: 25px; BACKGROUND-COLOR: #ebf4fd } TD.editHeaderTd { PADDING-LEFT: 50px; FONT-WEIGHT: bold } TR.editTr { HEIGHT: 30px } TD.editLeftTd { WIDTH: 150px; BACKGROUND-COLOR: #fffdf0; TEXT-ALIGN: center } TD.editRightTd { PADDING-LEFT: 10px; BACKGROUND-COLOR: #fff } TR.editFooterTr { HEIGHT: 40px; BACKGROUND-COLOR: #ebf4fd } TD.editFooterTd { PADDING-LEFT: 150px } </style> <SCRIPT language=javascript> function expand(el) { childObj = document.getElementById("child" + el); if (childObj.style.display == 'none') { childObj.style.display = 'block'; } else { childObj.style.display = 'none'; } return; } </SCRIPT> </HEAD> <BODY> <TABLE height="100%" cellSpacing=0 cellPadding=0 width=170 background=images/menu_bg.jpg border=0> <TR> <TD vAlign=top align=middle> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <TR> <TD height=10></TD></TR></TABLE> <TABLE cellSpacing=0 cellPadding=0 width=150 border=0> <TR height=22> <TD style="PADDING-LEFT: 30px" background=images/menu_bt.jpg><A class=menuParent onclick=expand(1) href="javascript:void(0);">關於我們</A></TD></TR> <TR height=4> <TD></TD></TR></TABLE> <TABLE id=child1 style="DISPLAY: none" cellSpacing=0 cellPadding=0 width=150 border=0> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>公司簡介</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>榮譽資質</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>分類管理</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>子類管理</A></TD></TR> <TR height=4> <TD colSpan=2></TD></TR></TABLE> <TABLE cellSpacing=0 cellPadding=0 width=150 border=0> <TR height=22> <TD style="PADDING-LEFT: 30px" background=images/menu_bt.jpg><A class=menuParent onclick=expand(2) href="javascript:void(0);">新聞中心</A></TD></TR> <TR height=4> <TD></TD></TR></TABLE> <TABLE id=child2 style="DISPLAY: none" cellSpacing=0 cellPadding=0 width=150 border=0> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>公司新聞</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>分類管理</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>子類管理</A></TD></TR> <TR height=4> <TD colSpan=2></TD></TR></TABLE> <TABLE cellSpacing=0 cellPadding=0 width=150 border=0> <TR height=22> <TD style="PADDING-LEFT: 30px" background=images/menu_bt.jpg><A class=menuParent onclick=expand(3) href="javascript:void(0);">產品中心</A></TD></TR> <TR height=4> <TD></TD></TR></TABLE> <TABLE id=child3 style="DISPLAY: none" cellSpacing=0 cellPadding=0 width=150 border=0> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>產品展示</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>最新產品</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>分類管理</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>子類管理</A></TD></TR> <TR height=4> <TD colSpan=2></TD></TR></TABLE> <TABLE cellSpacing=0 cellPadding=0 width=150 border=0> <TR height=22> <TD style="PADDING-LEFT: 30px" background=images/menu_bt.jpg><A class=menuParent onclick=expand(4) href="javascript:void(0);">客戶服務</A></TD></TR> <TR height=4> <TD></TD></TR></TABLE> <TABLE id=child4 style="DISPLAY: none" cellSpacing=0 cellPadding=0 width=150 border=0> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>客戶服務</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>分類管理</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>子類管理</A></TD></TR> <TR height=4> <TD colSpan=2></TD></TR></TABLE> <TABLE cellSpacing=0 cellPadding=0 width=150 border=0> <TR height=22> <TD style="PADDING-LEFT: 30px" background=images/menu_bt.jpg><A class=menuParent onclick=expand(5) href="javascript:void(0);">經典案例</A></TD></TR> <TR height=4> <TD></TD></TR></TABLE> <TABLE id=child5 style="DISPLAY: none" cellSpacing=0 cellPadding=0 width=150 border=0> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>分類管理</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>子類管理</A></TD></TR> <TR height=4> <TD colSpan=2></TD></TR></TABLE> <TABLE cellSpacing=0 cellPadding=0 width=150 border=0> <TR height=22> <TD style="PADDING-LEFT: 30px" background=images/menu_bt.jpg><A class=menuParent onclick=expand(6) href="javascript:void(0);">高級管理</A></TD></TR> <TR height=4> <TD></TD></TR></TABLE> <TABLE id=child6 style="DISPLAY: none" cellSpacing=0 cellPadding=0 width=150 border=0> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>廣告管理</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>訪問統計</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>郵件發送設置</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>聯系部門</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>用戶留言</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>招聘職位</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>應聘人員</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>留言簿</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>產品訂購</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>鏈接管理</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>文件管理</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>信息轉移</A></TD></TR> <TR height=4> <TD colSpan=2></TD></TR></TABLE> <TABLE cellSpacing=0 cellPadding=0 width=150 border=0> <TR height=22> <TD style="PADDING-LEFT: 30px" background=images/menu_bt.jpg><A class=menuParent onclick=expand(7) href="javascript:void(0);">系統管理</A></TD></TR> <TR height=4> <TD></TD></TR></TABLE> <TABLE id=child7 style="DISPLAY: none" cellSpacing=0 cellPadding=0 width=150 border=0> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>基本設置</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>樣式管理</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>欄目管理</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>功能管理</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>菜單管理</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>首頁設置</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>管理員列表</A></TD></TR> <TR height=4> <TD colSpan=2></TD></TR></TABLE> <TABLE cellSpacing=0 cellPadding=0 width=150 border=0> <TR height=22> <TD style="PADDING-LEFT: 30px" background=images/menu_bt.jpg><A class=menuParent onclick=expand(0) href="javascript:void(0);">個人管理</A></TD></TR> <TR height=4> <TD></TD></TR></TABLE> <TABLE id=child0 style="DISPLAY: none" cellSpacing=0 cellPadding=0 width=150 border=0> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild href="#" target=main>修改口令</A></TD></TR> <TR height=20> <TD align=middle width=30><IMG height=9 src="images/menu_icon.gif" width=9></TD> <TD><A class=menuChild onclick="if (confirm('確定要退出嗎?')) return true; else return false;" href="http://www.jb51.net" target=_top>退出系統</A></TD></TR></TABLE></TD> <TD width=1 bgColor=#d1e6f7></TD></TR></TABLE></BODY></HTML>
希望本文所述對大家的JavaScript程序設計有所幫助。