javascript - How to overlay one div over another? -


when hover mouse on div id one, dialog box appears, div id 3 moves right.

i want dialog box appear on div id 3 without moving right.

html page

<!doctype html> <html> <head> <style> div{ width:300px; height:300px; border:1px solid #000000; float:left; margin-left:10px; } #one,#three{ position:relative; } #two,#four{ margin:0; padding:0; left:334px; top:100px; background-color:#3b3b3b; border:none; width:200px; height:100px; display:none; position:relative; left:14px; } #triangleone,#triangletwo{ margin:0; padding:0; width: 0; height: 0; border-color:transparent; border-top: 8px solid transparent; border-right: 14px solid #3b3b3b; border-bottom: 8px solid transparent; top:35px; display:none; position:relative;  } #dialogboxone,#dialogboxtwo{ margin:0; padding:0; width:214px; display:none; border:none; } </style> <script> var timer; function showdialogbox(idone,idtwo,idthree){ var firstsidebar=document.getelementbyid(idone); var secondsidebar=document.getelementbyid(idtwo); var dialogbox=document.getelementbyid(idthree); timer=settimeout(function(){ firstsidebar.style.display="block"; secondsidebar.style.display="block"; dialogbox.style.display="block"; },800); } function hidedialogbox(idone,idtwo,idthree){ cleartimeout(timer); var firstsidebar=document.getelementbyid(idone); var secondsidebar=document.getelementbyid(idtwo); var dialogbox=document.getelementbyid(idthree); firstsidebar.style.display="none"; secondsidebar.style.display="none"; dialogbox.style.display="none"; } </script> </head> <body> <div id="one" onmouseover="showdialogbox('two','triangleone','dialogboxone')" onmouseout=hidedialogbox('two','triangleone','dialogboxone')></div> <div id="dialogboxone"> <div id="two"></div> <div id="triangleone"></div> </div> <div id="three" onmouseover="showdialogbox('four','triangletwo','dialogboxtwo')" onmouseout="hidedialogbox('four','triangletwo','dialogboxtwo')"></div> <div id="dialogboxtwo"> <div id="four"></div> <div id="triangletwo"></div> </div> </body> </html> 

you need wrapper position dialogboxes against:

<div class="wrapper">     <div id="one"></div>      <div id="dialogone"></div> </div> 

then you'll need position wrapper relatively, , position them liking (eg. float). dialog can positioned absolutely, example: position: absolute; left: 100% position them outside wrapper right.

jsfiddle example

note: please try format code bit more readable, indents , spaces... whenyouwriteinenglishyoualsousespaces,doyou?


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -