1、在后台新建一个sql自定义标签,命名为“二级栏目”
查询:SELECT TOP 20 ID,FolderName,TN FROM KS_Class Where TN='{$Param(0)}' and TopFlag=1
循环:<ul>[loop=20]
<li><a href="{$Field(ID,GetInfoUrl,100,1)}">{$Field(FolderName,Text,0,...,0,)}</a></li>
[/loop]</ul>
2、新建一个sql自定义标签,命名为“一级栏目”
查询:SELECT TOP 20 ID,classid,FolderName,TS,TN FROM KS_Class Where tj=1 and TopFlag=1
循环:[loop=20]
<li><a href="{$Field(ID,GetInfoUrl,100,1)}" target="_blank">{$Field(FolderName,Text,0,...,0,)}</a>{SQL_二级栏目({$Field(ID,Text,0,...,0,)})}</li>
[/loop]
3、在模板head中间加上以下js代码:
<script type="text/javascript">
//下拉菜单js代码
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("menu");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
}
window.onload=startList;
</script>
4、模板调用:
<!--导航开始-->
<div id="nav">
<ul id="menu">
{SQL_一级栏目()}
</ul>
</div>
<div class="claer"></div>
<!--导航结束-->
5、css部分【实现效果的关键部分】
/* 导航 */
/* 一级导航 */
#nav { background-image: url(nav_0bg.jpg); background-repeat: no-repeat; height: 43px; width: 811px; margin-top: 0px; margin-right: auto; margin-bottom: 0px; margin-left: auto; padding-left: 45px; }
#menu ul { padding: 0; margin: 0; }
#menu li { position:relative; float: left; width: 85px; text-align: center; }
#menu li a { width: 85px; font-size: 13px; line-height: 43px; color: #FFFFFF; text-decoration: none; height: 43px; display: block; }
#menu li a:hover { width: 85px; color: #006600; text-decoration: none; height: 43px; background-image: url(nav.jpg); background-repeat: no-repeat; background-position: center center; }
/* 二级导航 */
#menu li ul { position:absolute; display: none; top: 43px; left:0; }
#menu li:hover ul, #menu li.over ul { display: block; }
#menu ul li a { display:block; font-size:12px; padding:3px; margin-right:1px; text-decoration: none; color: #000000; background:#eee; line-height: 14px; height: 14px; }
#menu ul li a:hover { background-color:#DDDDDD; line-height: 14px; height: 14px; background-image: none; }
看懂代码后自己修改吧
效果截图
此主题相关图片如下:qq截图未命名.png