PDA

View Full Version : Changing the Z-Index


hoodymahood
12-23-2002, 09:59 PM
How can i change the Z-Indexing of a layer so it will be shown infront of the other layers.

What would be great if yuo could click a picture and a layer moves from underneath to ontop

ConfusedOfLife
12-23-2002, 10:20 PM
Hi, well, for changing the z-index you just have to change it! it's very easy and is written exactly as you say:


<img src="something.jpg" style="z-index : 5">


and for the effect that you're talking about, I think not only you have to use the z-index, but you should also use filters ( especially the alpha) to get a beautiful effect, by z-index alone you just say which layer be on top, it doesn't give you the fading effect.
Also notice that certain elements in the page always stay on top of the others and they're not gonna be under anything else even if that element's z-index be 1000 times greater than our fiexed element. One of them as I can remember is the <select> tag, or simply the <input type=text>.

Algorithm
12-23-2002, 11:17 PM
I think you're looking for this:if(document.getElementById){
document.getElementById(layerName).style.zIndex = z;
} else if(document.all){
document.all[layerName].style.zIndex = z;
}This assumes you have predefined variables layerName (as a string) and z (as an integer). Replace these with whatever you need.

dhtmlx
12-24-2002, 12:58 AM
also dont forget:

if (document.layers) {
document.layers[layername].style.zIndex = z;
}

I hate cross browsering