为什么 jQuery .animate({opacity:0}) 也会改变 z-index
基本上标题说明了一切 - 为什么 jQuery .animate({opacity:0}) 也改变了 z-index?
你知道如何解决吗?
编辑:
链接到示例: http://jsfiddle.net/4vUc7/
谢谢。
Basically the title says everything - why jQuery .animate({opacity:0}) changes the z-index too?
Do you know how to solve it?
EDIT:
link to example: http://jsfiddle.net/4vUc7/
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的
z-index
中缺少分号这是更新后的 fiddle
You were missing a semicolon in your
z-index
Here is the updated fiddle
正如jen链接的问题中提到的,这不是 jQuery bug,而是浏览器问题。如果您在调试控制台中监视不透明度被切换的元素的属性,您会注意到只有不透明度被触及。 jQuery 没有触及
z-index
,但浏览器以不同的方式呈现不透明度不等于 1 的元素。我对您的代码做了一些额外的更改: http://jsfiddle.net/radu/4vUc7 /6/。
As mentioned in the question linked by jen, this is not a jQuery bug but a browser problem. If you monitor the properties of the element whose opacity is being toggled in a debug console you'll notice that only opacity is being touched. jQuery is not touching the
z-index
, but the browser renders elements with opacity that isn't equal to 1 differently.I've made a few extra changes to your code: http://jsfiddle.net/radu/4vUc7/6/.