javascript - Issue in displaying pop-up div over target element -
i trying display popup div onmousehover on image. currently, pop displayed under scroll bar. need display floating popup type on scroll bar of div instead of hidding beneath scroll bar.
thanks in advance!
sample code:
css
.popbox { margin: -50px 50px 0px 50px; z-index: 2; width: 60px; padding: 0.3em; border: 1px solid gray; } .images { width: 50px; height: 50px; border-radius: 5px; } div.scroll { background-color: #00ffff; width:80px; height: 200px; overflow: scroll; } </style>
javascript
<script> function showbox(text, obj) { helpnode = document.createelement('div'); helpnode.id = 'popbox'; helpnode.setattribute('class','popbox'); helpnode.innerhtml = text; obj.appendchild(helpnode); } function hidebox() { node = document.getelementbyid('popbox'); node.parentnode.removechild(node); } </script>
html
<body> <div class="scroll" style="margin:0px auto"> <b onmouseover="showbox('<b>foo1</b><br /> bar1', this)" onmouseout="hidebox()" ><input type="image" class="images" src="http://www.picgifs.com/clip-art/flowers-and-plants/flowers/clip-art-flowers-511058.jpg" /></b></br> <b onmouseover="showbox('<b>foo2</b><br /> bar2', this)" onmouseout="hidebox()" ><input type="image" class="images" src="http://www.picgifs.com/clip-art/flowers-and-plants/flowers/clip-art-flowers-380016.jpg" /></b></br> <b onmouseover="showbox('<b>foo3</b><br /> bar3', this)" onmouseout="hidebox()" ><input type="image" class="images" src="http://www.picgifs.com/clip-art/flowers-and-plants/flowers/clip-art-flowers-293063.jpg" /></b></br> <b onmouseover="showbox('<b>foo4</b><br /> bar4', this)" onmouseout="hidebox()" ><input type="image" class="images" src="http://www.picgifs.com/clip-art/flowers-and-plants/flowers/clip-art-flowers-611834.jpg" /></b></br> </div> </body> </html>
try adding position: absolute; .popbox
css
.popbox { margin: -50px 50px 0px 50px; z-index: 2; width: 60px; padding: 0.3em; border: 1px solid gray; position: absolute; } .images { width: 50px; height: 50px; border-radius: 5px; } div.scroll { background-color: #00ffff; width:80px; height: 200px; overflow: scroll; }
javascript
function showbox(text, obj) { helpnode = document.createelement('div'); helpnode.id = 'popbox'; helpnode.setattribute('class','popbox'); helpnode.innerhtml = text; obj.appendchild(helpnode); } function hidebox() { node = document.getelementbyid('popbox'); node.parentnode.removechild(node); }
html
<div class="scroll" style="margin:0px auto"> <b onmouseover="showbox('<b>foo1</b><br /> bar1', this)" onmouseout="hidebox()" ><input type="image" class="images" src="http://www.picgifs.com/clip-art/flowers-and-plants/flowers/clip-art-flowers-511058.jpg" /></b></br> <b onmouseover="showbox('<b>foo2</b><br /> bar2', this)" onmouseout="hidebox()" ><input type="image" class="images" src="http://www.picgifs.com/clip-art/flowers-and-plants/flowers/clip-art-flowers-380016.jpg" /></b></br> <b onmouseover="showbox('<b>foo3</b><br /> bar3', this)" onmouseout="hidebox()" ><input type="image" class="images" src="http://www.picgifs.com/clip-art/flowers-and-plants/flowers/clip-art-flowers-293063.jpg" /></b></br> <b onmouseover="showbox('<b>foo4</b><br /> bar4', this)" onmouseout="hidebox()" ><input type="image" class="images" src="http://www.picgifs.com/clip-art/flowers-and-plants/flowers/clip-art-flowers-611834.jpg" /></b></br> </div>
Comments
Post a Comment