很多用戶想實(shí)現(xiàn)自定義下拉菜單,其他不說了,看下面吧,CSS都已經(jīng)注釋。
在風(fēng)格治理里面添加下面的CSS,直接把下面 CSS代碼 復(fù)制到風(fēng)格最底部即可:
css代碼:/*下拉菜單樣式*/
*{margin:0;padding:0;border:0;}#div_center { width:790px; height:23px; background:#003399; margin-left: auto;margin-right:auto;} /*定義總體寬度、高度;background:003399; 控制背景顏色,居中對(duì)齊*/ #nav { line-height: 20px; list-style-type: none; margin-top:5px;} /*控制一級(jí)菜單行高;上邊距5px;*/ #nav a { display: block; width: 77px; text-align:center; font-size:12px;} /*一級(jí)菜單鏈接總體樣式:每個(gè)菜單的寬,居中對(duì)齊,文字大小*/ #nav a:link { color:#FFF; text-decoration:none;margin:0;} /* 未訪問的鏈接 */ #nav a:visited {color:#FFF;text-decoration:none;margin:0;} /* 已訪問的顏色 */ #nav a:hover {color:#C00;text-decoration:none;} /* 鼠標(biāo)在鏈接上 */
#nav li {float: left;} /* 一級(jí)菜左對(duì)齊 */ #nav li a:hover{background:#FFFFFF;} /* 鼠標(biāo)在一級(jí)菜單上改變其背景色 */ #nav li ul {line-height: 24px; background:#FFF; list-style-type: none;text-align:left;left: -999em; width:132px; position: absolute;border-width: 1px;border-top-style: none;border-right-style: solid;border-bottom-style: solid;border-left-style: solid;border-color: #003399; padding:1px;} /*二級(jí)菜單總體樣式:行高24px;背景顏色;外框?qū)挾龋幌鄬?duì)位置;邊框一個(gè)象素,上邊沒樣式,左右下邊實(shí)線,邊框顏色#003399;內(nèi)邊距1個(gè)象素*/
#nav li ul a{display:block; width: 130px;text-align:left;padding-left:2px;} /* 二級(jí)菜單鏈接樣式;背景寬度、左對(duì)齊,左縮進(jìn)2 */#nav li ul a:link {color:#0d5097; text-decoration:none;} /* 未訪問的鏈接 */ #nav li ul a:visited {color:#0d5097;text-decoration:none;} /* 已訪問的鏈接 */#nav li ul a:hover {color:#FFF;text-decoration:none;font-weight:normal;background:#003399;}/* 鼠標(biāo)在鏈接上 */
#nav li:hover ul {left: auto;}#nav li.sfhover ul {left: auto;}#content {clear: left;}
把下面代碼插入模板里面,你想要顯示的地方:
DIV代碼:<script type=text/javascript><!--function menuFix() { var sfEls = document.getElementById("nav").getElementsByTagName("li"); for (var i=0; i<sfEls.length; i ) { sfEls[i].onmouseover=function() { this.className =(this.className.length>0? " ": "") "sfhover"; } sfEls[i].onMouseDown=function() { this.className =(this.className.length>0? " ": "") "sfhover"; } sfEls[i].onMouseUp=function() { this.className =(this.className.length>0? " ": "") "sfhover"; } sfEls[i].onmouseout=function() {
查看更多 動(dòng)易Cms教程 動(dòng)易Cms模板
復(fù)制本頁鏈接| 搜索DIV實(shí)現(xiàn)下拉菜單
動(dòng)易Cms教程-DIV實(shí)現(xiàn)下拉菜單。