为什么设置一个元素's zindex返回到0,不将其移动到IE9中的其他对象之后
Why does setting an element's zindex back to 0 not move it behind other objects in IE9?
这适用于IE 6、7、8、FF 3.5+、Chrome、Safari,但在IE 9中不行!我所做的就是把一个物体移到前面,然后再把它移回另一个物体后面。它移动到前面,但不会返回(尽管zIndex设置正确)。
所有对象的位置都是绝对的。
<!doctype html>
<html>
<head>
<title>Test</title>
</head>
<style>
body
{
background-color: #c6e2f1;
}
.moveable
{
position:absolute;
top: 300px;
left: 10px;
width: 200px;
height: 50px;
background-color: red;
z-index: 0;
}
.stationary
{
position:absolute;
top: 300px;
left: 0px;
width: 300px;
height: 100px;
background-color: yellow;
z-index: 1;
}
</style>
<body>
<div id="moveable" class="moveable"></div>
<div id="stationary" class="stationary"></div>
<script>
var up = false;
document.getElementById( "stationary" ).onclick = function()
{
if ( !up )
{
up = true;
document.getElementById( "moveable" ).style.zIndex = 2;
}
else
{
document.getElementById( "moveable" ).style.zIndex = 0;
up = false;
}
}
</script>
</body>
</html>
我不知道IE9中为什么会发生这种情况,但您是否尝试过将每个起始z-index
增加1,这样就不会将其更改为2然后返回0,而是将其更改成3然后返回1。
<!doctype html>
<html>
<head>
<title>Test</title>
</head>
<style>
body
{
background-color: #c6e2f1;
}
.moveable
{
position:absolute;
top: 300px;
left: 10px;
width: 200px;
height: 50px;
background-color: red;
z-index: 1;
}
.stationary
{
position:absolute;
top: 300px;
left: 0px;
width: 300px;
height: 100px;
background-color: yellow;
z-index: 2;
}
</style>
<body>
<div id="moveable" class="moveable"></div>
<div id="stationary" class="stationary"></div>
<script>
var up = false;
document.getElementById( "stationary" ).onclick = function()
{
if ( !up )
{
up = true;
document.getElementById( "moveable" ).style.zIndex = 3;
}
else
{
document.getElementById( "moveable" ).style.zIndex = 1;
up = false;
}
}
</script>
</body>
</html>
var up = false;
document.getElementById( "stationary" ).onclick = function()
{
if ( !up )
{
up = true;
document.getElementById( "moveable" ).style.zIndex = '2';
}
else
{
document.getElementById( "moveable" ).style.zIndex = '-1';
up = false;
}
}
相关文章:
- Angular JS IE9 Hashbang url rewriting
- Canvas Html5绘图应用程序,移动画布会导致重大问题
- 正在SharePoint 2013母版页中添加JQuery移动文件
- 如何在android中使用phonegap将文件从一个文件夹移动/复制到另一个文件夹
- 如何使用phaser使html5游戏在移动设备浏览器上运行
- FabricJs-限制主对象内添加对象的移动区域
- 在Twitter上用ie9中的空白src访问iframe的contentWindow
- 如何从画布上的某个移动事件中获取X和Y
- 触摸移动时切换到新元素
- 每当您在选择器内移动鼠标时,悬停功能就会重复
- 停止jQuery UI滑块移动超过给定值
- 谷歌地图API v3不适用于移动浏览器或PhoneGap
- 在IE9中的输入字段中输入焦点最近按钮
- 如何将chrome扩展功能移植到移动设备(特别是jquery和trello)
- JQuery移动动态分区页面
- XMLHttpRequest在移动设备上的chrome上不起作用
- 为什么设置一个元素's zindex返回到0,不将其移动到IE9中的其他对象之后
- 取消IE9触摸滚动事件并调用鼠标移动(可能)
- IE9悬停bug -悬停状态在移动一行后保持不变
- IE9窗口失去焦点由于jQuery移动