Results 1 to 4 of 4

Thread: Dropdown content position

  1. #1
    Join Date
    May 2008
    Posts
    2
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Dropdown content position

    1) Script Title: Dropdown overlapping content

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

    3) Describe problem: Hi, I am using the script and it is working well except the overlapped content box is being positioned way to the right side. Apparently the script isn't calculating correctly the position of the anchor and the margins on the overlapped content are being set with this wrong values. How can I use the vertical and horizontal offset parameters to correct the position?

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

    Default

    You shouldn't have to use the vertical/horizontal offset settings to correct the problem. Most of the positioning problems with the drop down DIV can be solved by making sure the HTML for the drop down DIVs themselves is outside any container tag on the page other than the BODY. So in your case, try moving all the drop down DIVs to the bottom of your page, just above the "</body>" tag, for example:

    Code:
    <DIV id="subcontent2" style="position:absolute; visibility: hidden; border: 9px solid black; background-color: lightyellow; width: 350px; height: 120px; padding: 4px;">
    
    <div style="width: 49%; float: left">
    <ul>
    <li><a href="http://www.dynamicdrive.com">Dynamic Drive</li>
    <li><a href="http://www.javascriptkit.com">JavaScript Kit</li>
    <li><a href="http://www.cssdrive.com">CSS Drive</li>
    <li><a href="http://www.codingforums.com">Coding Forums</li>
    </ul>
    </div>
    </body>
    If you need more help please post a link to the page on your site that contains the problematic script so we can check it out.

  3. The Following User Says Thank You to ddadmin For This Useful Post:

    carsal (05-07-2008)

  4. #3
    Join Date
    May 2008
    Posts
    2
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the prompt reply. Unfortunately this is not possible as this is part of a php generated page, so the only option I have is correct the problem with offsets, however I can't seem to find a way to include the offsets without modifying the script as I use it for several div's. Is there a way to pass the offset either in the div or on the script function call.

    Thanks.

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

    Default

    You'll want to find a dynamic way to reposition the drop down DIV based on the additional offsets of the DIV it's contained in. For example, lets say your drop down DIV is inside the DIV in red below:

    Code:
    <div id="test" style="position:relative; left:100px; top:50px">
    
    <p>Demo #1: <a href="http://www.dynamicdrive.com" id="searchlink" rel="subcontent">Search DD</a></p>
    
    
    <DIV id="subcontent" style="position:absolute; visibility: hidden; border: 9px solid orange; background-color: white; width: 300px; padding: 8px;">
    
    <p><b>Search Dynamic Drive:</b></p>
    <form method="get" action="http://search.freefind.com/find.html" id="topform">
    <input name="query" maxlength="255" style="width: 150px" id="topsearchbox" alt="Search" /> 
    <input value="Search" class="topformbutton" type="submit" />
    </form>
    
    <div align="right"><a href="javascript:dropdowncontent.hidediv('subcontent')">Hide this DIV manually</a> | <a href="http://www.dynamicdrive.com">Dynamic Drive</a></div>
    
    
    </DIV>
    
    </div>
    If you try the above out, you'll notice how the DIV is positioned incorrectly as a result, namely, 100px to the right and 50px down where it should be. Normally the solution is just to move the drop down DIV outside the DIV in red, but since you can't do that, you'll need to tell the script to take into account the additional offset. Inside the .js file for example:

    Code:
    subobj.style.left=this.getposOffset(anchorobj, "offsetLeft") + 100 + horizontaloffset + "px"
    subobj.style.top=this.getposOffset(anchorobj, "offsetTop")+50+verticaloffset+"px"
    That's the general idea anyway.

  6. The Following User Says Thank You to ddadmin For This Useful Post:

    carsal (05-08-2008)

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
  •