I would like to position my div according to where I am located on my page
I would like to position my div according to where I am located on my page
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!
its page with many link calling for "floating divs".
so I want my div to appear more or elss where the link is
Wrote this script yesterday:
Whereas, the "text to show" is where your div content is.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>
- Mike
thank you very much
is there a way I can define that the div will be on top of the link(not bottom)
Replace:
With:Code:el.style.top = cur.offsetTop+cur.offsetHeight+"px"
Code:el.style.top = cur.offsetTop-cur.offsetHeight-el.offsetHeight+"px"
- Mike
Bookmarks