Forum Moderators: not2easy

Message Too Old, No Replies

questions about Z index

         

rst2

9:56 pm on Jul 21, 2009 (gmt 0)

10+ Year Member



Hello,
I'm using a little bit of javascript to show and hide a div tag. I'm trying to use the css z index to keep the newly revealed div above the rest of the page. I have created a simple test below. Any Suggestions would be greatly appreciated.
Ray


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<title>test</title>
</head>

<body>
<div id="block1" style="position:relative; z-index: 10;">
<a href="#" onmouseover="javascript:document.getElementById('block1a').style.display = 'block';" onmouseout="javascript:document.getElementById('block1a').style.display = 'none';">the answer will be revealed</a>
<div id="block1a" style="display: none; position:relative; z-index: 10;"><h1>42</h1></div>
</div>
This text should not move.
</body>
</html>

Gibble

5:20 pm on Jul 22, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



use visibility instead of display, it retains the objects position in the document