firefox中的3D转换问题

时间:2014-11-17 05:46:22

标签: css3 firefox webkit-perspective

我有一张JSFiddle显示翻转卡片,它正如我所期望的那样在Chrome中运行,但是Firefox中的深度视角是平坦的,我不确定问题出在哪里。

我尝试过添加:

transform-style: preserve-3d;

perspective: 1000;

所有课程(如卡片)我都没有运气。

HTML结构是:

<div id="card-container">
    <button id="card-flip">Flip the card</button>
    <div id="card">
        <div class="front card-surface"><!-- front -->
            <p>The front</p>
        </div>
        <div class="back card-surface"><!-- back -->
            <p>The back</p>
        </div>
    </div>
</div>

简化的CSS是:

#card-container{
    position: relative;
    background-color:#888;
    width: 300px;
    height: 450px;
    margin:0 auto;
}
#card-flip{
    display:none;
}
#card{
    margin:10px auto;
    width: 100%;
    height: 400px;
}
.card-surface{
    margin-top:5px;
    width: 280px;
    height: 180px;
    padding:10px;
}
.front{
     background-color:#7B78E8;   
}
.back{
     background-color:#78AFE8;   
}
/* Only apply 3d effects if they exist in the browser */

#card-container.threed{
    height: 250px;
    perspective: 1000;
}
.threed #card-flip{
    background-color:transparent;
    position:relative;
    top:220px;
    width:100%;
    height:40px;
    background-color:#99E5FF;
}
.threed #card-flip:focus{
    outline:0;
}
.threed #card-flip:hover{
    background-color:#49A5BF;
}
#card-flip:hover + #card .card-surface{
    box-shadow: 0 0px 50px rgba(0,0,0,0.9);
    transition: all .8s ease-in-out;
}
.threed #card{
    height:200px;   
}
.threed #card .front {
    float: none;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 900;

    transform: rotateX(0deg) rotateY(0deg);

    transform-style: preserve-3d;

    backface-visibility: hidden;
}

.threed #card.flip .front {
    z-index: 900;
    border-color: #eee;
    background: #333;
    box-shadow: 0 15px 50px rgba(0,0,0,0.2);

    transform: rotateY(180deg);
}

.threed #card .back {
    float: none;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 800;
    border: 1px solid #ccc;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.6);

    transform: rotateY(-180deg);

    transform-style: preserve-3d;

    backface-visibility: hidden;
}

.threed #card.flip .back {
    z-index: 1000;
    background-color:#ccc;
    transform: rotateX(0deg) rotateY(0deg);
}
.threed #card .card-surface{
    background-color:$base-white;
    transition: all .8s ease-in-out;
    width: 280px;
    height: 180px;
    padding:10px;
}

我见过像This one这样的工作示例。任何人都可以告诉我我缺少什么或者这种结构不可能吗?

1 个答案:

答案 0 :(得分:0)

我已经找到了问题。

以下是fiddle的新版本。 问题是我在透视属性之后没有px。这被chrome忽略但不是firefox。我还将透视应用于演示中的错误元素,因此即使我尝试在px之前对其进行广告也不起作用。

相关问题