z-index 在 Firefox 中的表现有所不同
我有以下代码
#flipper #Front {
z-index:81;
}
#flipper #Back {
z-index:80;
}
.face{
position:absolute;
width:100%;
height:100%;
}
.front{
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
}
#flipper > * {
max-width:100px;
cursor:pointer;
}
<div id='flipper'>
<div id='Front' class='front face'>
<img src='images/front.gif'>
</div>
<div id='Back' class='back face'>
<img src='images/back.gif'>
<a href="/link" title="get in /here/" style="position: relative; top: -100px; display:none;">peek</a>
</div>
</div>
和脚本
/* flip */
function flipOwlly() {
if (Side=='front') {
jQuery('#flipper').css('-webkit-transform','rotateY(180deg)');
jQuery('#flipper').css('-moz-transform','rotateY(180deg)');
jQuery('#Front').css('z-index','79');
jQuery('#flipper a[href="/login"]').css('display', 'inline-block');
Side = 'back';
} else {
jQuery('#flipper').css('-webkit-transform','rotateY(360deg)');
jQuery('#flipper').css('-moz-transform','rotateY(360deg)');
//setTimeout(jQuery('#Front').css('z-index','81'), 550);
jQuery('#Front').css('z-index','81');
owllySide = 'front';
}
return false;
}
编辑为添加 JS 代码
,并且我有一个 jquery 代码来运行 css 动画以翻转整个 #flipper 元素,然后将前面的 z-index 更改为 79 [和后面]。
我的问题是这在 Firefox 和 Chrome 上显示不同。在 Firefox 中,较高的 z-index 数字会将我的图像发回!所以当页面加载时,逻辑顺序是可以的,但是背面图像位于正面之上......
即使 IE 也可以正常渲染!这是怎么回事?
i have the following code
#flipper #Front {
z-index:81;
}
#flipper #Back {
z-index:80;
}
.face{
position:absolute;
width:100%;
height:100%;
}
.front{
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
}
#flipper > * {
max-width:100px;
cursor:pointer;
}
<div id='flipper'>
<div id='Front' class='front face'>
<img src='images/front.gif'>
</div>
<div id='Back' class='back face'>
<img src='images/back.gif'>
<a href="/link" title="get in /here/" style="position: relative; top: -100px; display:none;">peek</a>
</div>
</div>
and script
/* flip */
function flipOwlly() {
if (Side=='front') {
jQuery('#flipper').css('-webkit-transform','rotateY(180deg)');
jQuery('#flipper').css('-moz-transform','rotateY(180deg)');
jQuery('#Front').css('z-index','79');
jQuery('#flipper a[href="/login"]').css('display', 'inline-block');
Side = 'back';
} else {
jQuery('#flipper').css('-webkit-transform','rotateY(360deg)');
jQuery('#flipper').css('-moz-transform','rotateY(360deg)');
//setTimeout(jQuery('#Front').css('z-index','81'), 550);
jQuery('#Front').css('z-index','81');
owllySide = 'front';
}
return false;
}
EDITED TO ADD JS CODE
and i have a jquery code to run css animation for flipping the whole #flipper element, and then changing the front z-index to 79 [and back].
my problem is that this displays differently on firefox and chrome. in firefox, higher z-index number send my image back! so when the page loads, the logical order is ok, but the back image is on top of the front on....
even IE renders it fine! whats going on?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
发布你的 jquery 代码可能会有所帮助。不管怎样,我测试了翻转 z-index,它似乎正在工作:
但是,如果你只是尝试在图像之间切换,最好切换它们的可见性而不是它们的 z 索引:
Posting your jquery code could help. Anyway, I tested flipping the z-index and it seems to be working:
However, if you are just trying to toggle between the images, it would be better to toggle their visibility rather than their z-indexes:
我解决这个问题的方法是一种解决方法,我真的不喜欢,但这是我能找到的唯一方法..
因为我每侧都有 2 个 div,所以我只需“显示:无”-ed 背面一个,因此,即使浏览器错误地决定显示它,它也不会!
the way i fixed this was kind of workaround, which i really dont like, but it was the only way i could find..
since i have 2 div for each side, i simply 'display:none'-ed the back face one, so even if a browser wrongfully decides to display it, it won't!