View Full Version : zIndex question

Jan 29th, 2007, 09:53 AM
Hi. Im trying to overlay a div box over a input element so this overlay div should act as a modal over the input element, but i think im doing something wrong. Plese refer to the code snippet below:

<script type="text/javascript">
var oModalBackground = document.createElement('div');
oModalBackground.className = "modalBackground";
oModalBackground.style.width = 800;
oModalBackground.style.height = 800;
oModalBackground.style.position = "absolute";
oModalBackground.style.zIndex = 10000;

<style type="text/css">
border:solid 1px #ccc;

<input type="button" value="teste" />

The button is still clickable!

Jan 29th, 2007, 10:00 PM
You haven't assigned a zIndex to the button and it therefore automatically gets one theat is one greater than that of the previous element which puts it in front of your modal div.

Jan 29th, 2007, 11:44 PM
oModalBackground.style.width = 800;
oModalBackground.style.height = 800;The button is still clickable!For one, units are required in CSS. Thus:

oModalBackground.style.width = "800px";
oModalBackground.style.height = "800px";