当前位置: 代码迷 >> Web前端 >> 测试:z-Index 成效
  详细解决方案

测试:z-Index 成效

热度:456   发布时间:2012-09-09 09:27:54.0
测试:z-Index 效果

<html>
<head>
<title></title>
<script>
function plusDiv() {
  var div1 = document.getElementById('div1');
  var div2 = document.getElementById('div2');
  if (div1.style.zIndex > div2.style.zIndex) {
    div1.style.zIndex = div1.style.zIndex - 2;
  } else {
    div2.style.zIndex = div2.style.zIndex - 2;
  }
}
</script>
</head>
<body>
<div id="div1" style="position:absolute;z-index:1;width:100;height:100;background-color:#FF0000;left:0;top:0"></div>
<div id="div2" style="position:absolute;z-index:2;width:100;height:100;background-color:#00FF00;left:10;top:10"></div>
<input type="button" onclick="plusDiv()" value="交替底层出现" style="z-index:100;position:absolute;left:300" />
</body>
</html> 
?
  相关解决方案