PDA

View Full Version : Quick Question: AnyLink Drop Down Menu



Anonymous
04-24-2007, 05:36 PM
1) Script Title: AnyLink Drop Down Menu

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/dropmenuindex.htm

3) Describe problem: Is it possible to align the links that drop down to centre? :confused: Here's a link - what I've got at the moment. (http://anonymous.zexxo.net/demo.html)

Thanks.

Anonymous.

boxxertrumps
04-24-2007, 06:47 PM
I am deeply hurt...
This:
menu1[0]='<align="center"><a href="avatars.html">Avatars</align></a>'
Should be this:
menu1[0]='<a class="cent" href="avatars.html">Avatars</a>'
with this in your CSS file.

.cent {text-align:center;}

ddadmin
04-24-2007, 06:51 PM
Warning: Please include a link to the DD script in question in your post. See this thread (http://www.dynamicdrive.com/forums/showthread.php?t=6) for the proper posting format when asking a question.

mburt
04-24-2007, 07:03 PM
Nope that won't work: anchors are inline elements, and so you are centering on it's own width:

<div class="cent"><a href="avatars.html">Avatars</a></div>
DIV's are block-level, which automatically makes its width 100&#37;, aligning the link in the middle.

Bob90
04-24-2007, 07:36 PM
replace these functions


function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=getposOffset(obj, "left", menuwidth)
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

And


function getposOffset(what, offsettype, menwid){
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;
}
//Add this line to center div
if(what.firstChild && what.firstChild.nodeType == 1 && offsettype=="left"){totaloffset+= parseInt( ( parseInt(what.firstChild.width)-parseInt(menwid) ) / 2 )};
return totaloffset;
}

Bob90
04-24-2007, 07:43 PM
Sorry, thought you wanted to center the DIV menu below the image....

Oh well, may be useful for some.

:(

Anonymous
04-25-2007, 05:33 PM
OK...


I am deeply hurt...
This:
menu1[0]='<align="center"><a href="avatars.html">Avatars</align></a>'
Should be this:
menu1[0]='<a class="cent" href="avatars.html">Avatars</a>'
with this in your CSS file.

.cent {text-align:center;}

Sorry,


Warning: Please include a link to the DD script in question in your post. See this thread for the proper posting format when asking a question.

Sorry, and thanks for the rest of your help. But it still refuses to work...

Anymore ideas?

The links that drop down just won't centre!

Anonymous