Posts

Showing posts with the label CSS

CSS ZIndex sample demo

CSS Z-Index The z-index property specifies the stack order of an element. The highest stack ordered element is visible in the screen. z-index works only on abosolute,relative and fixed positioned elements.   To specify the z-index of an element using css div { z-index: 1} Using javascript object.style.zIndex = 1; Sample to explain zIndex behavior. Copy paste the code, save as html and run it to see the behavior. Its self explanatory. <HTML> <HEAD> <TITLE>Z-index demo </TITLE> <script>  var array = new Array("a","b","c","d","e");  var id;  function dance(){  id = self.setInterval(function(){      changeIndex();     }, 200);  }          function changeIndex(){    var index = Math.floor(Math.random()*5);      var obj = $(array[index]);    obj.style.zIndex = obj.style.zIndex == 10 ? -1 : 10; ...