dedecms做下拉菜单:
将下面这段代码贴到templetsdefault ooter.htm文件里
<!-- //二级子类下拉菜单,考虑SEO原因放置于底部 --> <script></script> {dede:channelartlist typeid='top' cacheid='channelsonlist'}登录后复制
-
{dede:channel type='son' noself='yes'}
- [field:typename/] {/dede:channel}
以上代码可以看出,二级子类下拉菜单是由dropdown.js控制的,我们来看dropdown.js文件:
由以上的cssdropdown.startchrome("navMenu"),可以看出我们调用的是 startchrome:function()
var cssdropdown={ disappeardelay: 250, disablemenuclick: false, enableswipe: 1, enableiframeshim: 1, dropmenuobj: null, ie: document.all, firefox: document.getElementById&&!document.all, swipetimer: undefined, bottomclip:0, getposOffset:function(what, offsettype){ var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop; var parentEl=what.offsetParent; while (parentEl!=null){ totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop; parentEl=parentEl.offsetParent; } return totaloffset; }, swipeeffect:function(){ if (this.bottomclip<parseint this.bottomclip this.dropmenuobj.style.clip="rect(0 auto " else return this.swipetimer='setTimeout("cssdropdown.swipeeffect()", 10)' showhide:function if this.dropmenuobj.style.left='this.dropmenuobj.style.top="-500px"' cleartimeout obj.clip="rect(0 auto 0 0)" this.swipeeffect obj.visibility="visible" iecompattest:function clearbrowseredge:function var this.dropmenuobj.contentmeasure="this.dropmenuobj.offsetWidth" edgeoffset="this.dropmenuobj.contentmeasure-obj.offsetWidth" dropit:function this.dropmenuobj.style.visibility="hidden" this.clearhidemenu obj. this.dropmenuobj="document.getElementById(dropmenuID)" this.dropmenuobj. this.showhide this.dropmenuobj.x='this.getposOffset(obj, "left")' this.dropmenuobj.y='this.getposOffset(obj, "top")' this.dropmenuobj.style.top='this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px"' this.positionshim positionshim:function this.shimobject.style.width='this.dropmenuobj.offsetWidth+"px"' this.shimobject.style.height='this.dropmenuobj.offsetHeight+"px"' this.shimobject.style.left="this.dropmenuobj.style.left" this.shimobject.style.top="this.dropmenuobj.style.top" this.shimobject.style.display='(this.dropmenuobj.style.visibility=="visible")? "block" : "none"' hideshim:function contains_firefox:function while dynamichide:function this.delayhidemenu delayhidemenu:function this.delayhide="setTimeout("cssdropdown.dropmenuobj.style.visibility='hidden'; cssdropdown.hideshim()",this.disappeardelay) " clearhidemenu:function startchrome:function for menuitems cssdropdown.dropit document.write>') this.shimobject=document.getElementById("iframeshim") } } }</parseint>登录后复制
由上可以看出,var cssdropdown变量中有多个函数:
getposOffset:function(what, offsettype) swipeeffect:function() showhide:function(obj, e) iecompattest:function() clearbrowseredge:function(obj, whichedge) dropit:function(obj, e, dropmenuID) positionshim:function() hideshim:function() dynamichide:function(e) delayhidemenu:function() clearhidemenu:function() startchrome:function()登录后复制
更新一下!会发现导航栏已经出现下拉菜单了,只是背景是透明的,原因是没有背景图片。
然后我们可以对此下拉菜单添加背景图片和设置css样式。
推荐:dedecms使用教程
以上就是dedecms怎么做下拉菜单的详细内容,更多请关注慧达AI工具网其它相关文章!