sgray6
10-09-2007, 04:58 AM
I'm trying to layer divs using "z-index"s — one background div with an image and a div directly on top of that with text and links in it.
The trick is, I want the top div with text and links to be hidden when the cursor is not over it, and to show up only when moused over.
It seems a kind of Catch-22 to have a div that shows up when you mouseover itself, if it hides when your mouse is not over it.
I tried putting the onMouseOver and onMouseOut code in the top div, in the bottom div, and in a third empty div on top of the other two. It doesn't work at all if it's in the div with the text and links(as I expected) and if it's in the bottom div, it kind of works, but the text in the top div flashes on and off constantly as the cursor moves around in it, which also makes links in the text pretty hard to click. If it's in a third div on top of both of the other two, it works but you can't click any links as they're under that invisible top div.
It's something like (this example being the one with the onMouseOver & Out code in the div with text & links that I want show/hide):
<div id="background" style="position:absolute; top:0; left:0; width:276px; height:110px; z-index:1;"><img src="http://www.google.com/intl/en_ALL/images/logo.gif"></div>
<div id="text" onMouseOver="document.getElementById('text').style.visibility = 'visible'" onMouseOut="document.getElementById('text').style.visibility = 'hidden'" style="position:absolute; top:0; left:0; width:276px; height:110px; z-index:2; visibility:hidden;">bla bla bla <a href="http://www.google.com">bla</a> bla</div>
The trick is, I want the top div with text and links to be hidden when the cursor is not over it, and to show up only when moused over.
It seems a kind of Catch-22 to have a div that shows up when you mouseover itself, if it hides when your mouse is not over it.
I tried putting the onMouseOver and onMouseOut code in the top div, in the bottom div, and in a third empty div on top of the other two. It doesn't work at all if it's in the div with the text and links(as I expected) and if it's in the bottom div, it kind of works, but the text in the top div flashes on and off constantly as the cursor moves around in it, which also makes links in the text pretty hard to click. If it's in a third div on top of both of the other two, it works but you can't click any links as they're under that invisible top div.
It's something like (this example being the one with the onMouseOver & Out code in the div with text & links that I want show/hide):
<div id="background" style="position:absolute; top:0; left:0; width:276px; height:110px; z-index:1;"><img src="http://www.google.com/intl/en_ALL/images/logo.gif"></div>
<div id="text" onMouseOver="document.getElementById('text').style.visibility = 'visible'" onMouseOut="document.getElementById('text').style.visibility = 'hidden'" style="position:absolute; top:0; left:0; width:276px; height:110px; z-index:2; visibility:hidden;">bla bla bla <a href="http://www.google.com">bla</a> bla</div>