ie10中jquery库的z索引问题
我修改了来自的gallery脚本,它在除IE10之外的所有浏览器中都能正常工作。请参见此处:ie10中jquery库的z索引问题,jquery,z-index,internet-explorer-10,photo-gallery,Jquery,Z Index,Internet Explorer 10,Photo Gallery,我修改了来自的gallery脚本,它在除IE10之外的所有浏览器中都能正常工作。请参见此处:http://174.122.126.251/~arblock/index.html。这些照片本应将顶部图像“洗牌”到堆栈底部,但在IE10中,顶部照片仍保留在顶部 以下是修改后的脚本: $(document).ready(function() { var z = 0; var inAnimation = false;
http://174.122.126.251/~arblock/index.html
。这些照片本应将顶部图像“洗牌”到堆栈底部,但在IE10中,顶部照片仍保留在顶部
以下是修改后的脚本:
$(document).ready(function() {
var z = 0;
var inAnimation = false;
$('#pictures img').each(function() {
z++;
$(this).css('z-index', z);
});
function swapFirstLast() {
if(inAnimation) return false; //if already swapping pictures just return
else inAnimation = true; //set the flag that we process a image
$('#pictures img').each(function() { //process each image
if($(this).css('z-index') == z) { //if its the image we need to process
$(this).animate({ 'left' : '-' + $(this).width() + 'px' }, 'slow', function() { //animate the img above/under the gallery (assuming all pictures are equal height)
$(this).css('z-index', 1) //set new z-index
.animate({ 'left' : '0' }, 'slow', function() { //animate the image back to its original position
inAnimation = false; //reset the flag
});
});
} else { //not the image we need to process, only in/de-crease z-index
$(this).animate({ 'left' : '0' }, 'slow', function() { //make sure to wait swapping the z-index when image is above/under the gallery
$(this).css('z-index', parseInt($(this).css('z-index')) + 1); //in/de-crease the z-index by one
});
}
});
return false; //don't follow the clicked link
}
window.setInterval(swapFirstLast, 3000);
});
有人能理解为什么每个浏览器(甚至是旧版本的IE)都能做到这一点,但IE10却不行吗
提前感谢你的帮助
更新:
它在IE10中仍然不起作用,但我确实注意到,如果让它继续运行一段时间,最上面的图片最终会移到后面,但新的最上面的图片会做同样的事情并保持在最上面。很奇怪
更新#2:
我只是在IE10运行时调整了它的大小,它立即开始正常工作。知道是什么导致了这种奇怪的行为吗?谢谢 我也有同样的问题。我试过调整尺寸,它对我也很有效。然后我决定改变z索引被改变的顺序。我根据元素的z指数从高到低显示元素,这似乎对我很有用。祝你好运 我不知道具体原因,但我可以告诉你,
可能会奏效。不幸的是,这有点老套,不是一个直接的答案,因此它是一个评论是的,我知道。我绝望了!尝试我能想到的任何东西。哈哈,我已经把它移除了。我发现了这个问题,但我不知道为什么会发生。我删除了脚本所需的css之外的所有css,然后一次添加一个样式。事实证明,页脚样式包含position:relative。当我取下这个时,一切都很好。奇怪的是,footer div位于gallery的容器元素的外部和下方,所以我不知道为什么这会对gallery产生影响,而且只在IE10中。我已经解决了这个问题,但我仍然好奇为什么会发生这种情况。有没有人听说过这种情况,并能对此有所了解?