Results 1 to 7 of 7

Thread: Quick Question: AnyLink Drop Down Menu

  1. #1
    Join Date
    Apr 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Quick Question: AnyLink Drop Down Menu

    1) Script Title: AnyLink Drop Down Menu

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...pmenuindex.htm

    3) Describe problem: Is it possible to align the links that drop down to centre? Here's a link - what I've got at the moment.

    Thanks.

    Anonymous.
    Last edited by Anonymous; 04-25-2007 at 05:48 PM.

  2. #2
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    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;}
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  3. #3
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    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.

  4. #4
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Nope that won't work: anchors are inline elements, and so you are centering on it's own width:
    Code:
    <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.
    - Mike

  5. #5
    Join Date
    Feb 2007
    Location
    England
    Posts
    254
    Thanks
    0
    Thanked 5 Times in 5 Posts

    Default Try this.....

    replace these functions

    Code:
    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

    Code:
    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;
    }

  6. #6
    Join Date
    Feb 2007
    Location
    England
    Posts
    254
    Thanks
    0
    Thanked 5 Times in 5 Posts

    Default Whoops,

    Sorry, thought you wanted to center the DIV menu below the image....

    Oh well, may be useful for some.


  7. #7
    Join Date
    Apr 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    OK...

    Quote Originally Posted by boxxertrumps View Post
    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •