jquery - z-index 在 firefox 中表现不同

标签 jquery css cross-browser z-index

我有以下代码

#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 也能正常显示!怎么回事?

最佳答案

发布您的 jquery 代码可能会有所帮助。无论如何,我测试了翻转 z-index 和它 seems to be working :

$(document).ready(function()
{
    $("#flipper").click(function()
    {
        $("#Front").css("z-index", $("#Front").css("z-index") == "79" ? "81" : "79"); 
    });
});

但是,如果您只是想在图像之间切换,最好是 toggle their visibility而不是他们的 z 索引:

#flipper #Back 
{
    display: none;
}

$(document).ready(function()
{
    $("#flipper").click(function()
    {                     
        $("#Front").toggle();
        $("#Back").toggle();
    });
});

关于jquery - z-index 在 firefox 中表现不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7175481/

相关文章:

jquery - URL 可以告诉 jQuery 运行一个函数吗?

javascript - 使用 jQuery .submit() 检索提交的表单的 ID 和/或名称

jquery - 如何创建带有换行符的选项卡?

html - 我将如何修改 <div> 元素以同时在网页上居中并保持其大小属性?

jquery - IE 中的样式(jquery)复选框按钮自动换行

javascript - 使用 Javascript 更改鼠标滚轮/触控板灵敏度

CSS HTML5 表格 <td> 被 <tr> 覆盖

internet-explorer - W3C 验证的 CSS 是否自动意味着跨浏览器兼容性?

css - Firefox 3.6 和 Firefox 4 之间的水平导航 CSS 区别

javascript - Javascript事件处理历史记录