Results 1 to 6 of 6

Thread: location of div

  1. #1
    Join Date
    Dec 2005
    Posts
    133
    Thanks
    23
    Thanked 0 Times in 0 Posts

    Default location of div

    I would like to position my div according to where I am located on my page

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    And where are you located on your page?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Dec 2005
    Posts
    133
    Thanks
    23
    Thanked 0 Times in 0 Posts

    Default

    its page with many link calling for "floating divs".
    so I want my div to appear more or elss where the link is

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

    Default

    Wrote this script yesterday:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Hover</title>
    <style type="text/css">
    .dialog {
    position:absolute;
    padding:3px;
    border:1px solid gray;
    font:10pt arial;
    display:none;
    }
    </style>
    <script type="text/javascript">
    function show(cur,element) {
      var el = document.getElementById(element);
      if (el.style.display == "block") {
        el.style.display = "none";
        }
      else {
        el.style.left = cur.offsetLeft+"px";
        el.style.top = cur.offsetTop+cur.offsetHeight+"px";
        el.style.display = "block";
        }
      return false;
      }
    </script>
    </head>
    <body>
    <a href="#" onclick="return show(this,'dlg1');">Test</a>
    <div id="dlg1" class="dialog">
    Text to show.
    </div>
    </body>
    </html>
    Whereas, the "text to show" is where your div content is.
    - Mike

  5. #5
    Join Date
    Dec 2005
    Posts
    133
    Thanks
    23
    Thanked 0 Times in 0 Posts

    Default

    thank you very much

    is there a way I can define that the div will be on top of the link(not bottom)

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

    Default

    Replace:
    Code:
    el.style.top = cur.offsetTop+cur.offsetHeight+"px"
    With:
    Code:
    el.style.top = cur.offsetTop-cur.offsetHeight-el.offsetHeight+"px"
    - Mike

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
  •