我有一张卡片,上面有关于前面和后面的信息。回来,当用户将鼠标悬停在卡片上时,它会切换并显示背面的信息。它适用于Firefox但不适用于Chrome / Safari,在这些浏览器中,虽然我尝试使用z-index值,但背面的文本仍被阻止。有一点需要考虑,卡的背面允许溢出容器,这是故意的。有人能指出我需要为其他两个浏览器添加什么内容吗?
CSS基于这篇文章:http://css3.bradshawenterprises.com/flip/
实施:https://jsfiddle.net/af75qzqm/
示例屏幕截图:
适用于Firefox
在Chrome中不起作用
#f1_container {
position: relative;
width: 250px;
height: 80px;
margin-left: 10px;
margin-right: 10px;
margin-bottom: 23px;
z-index: 0;
overflow: visible;
-webkit-perspective: 1000;
-moz-perspective: 1000;
-ms-perspective: 1000;
-o-perspective: 1000;
}
#f1_card {
position: relative;
width: 100%;
height: 100%;
background-color: #ffffff;
border: 3px solid transparent;
border-radius: 3px;
-webkit-box-shadow: 0 1px 1px #aaa;
transform-style: preserve-3d;
-webkit-transform-style: preserve-3d;
-webkit-transition: all 0.2s linear;
-moz-transform-style: preserve-3d;
-moz-transition: all 0.2s linear;
-ms-transform-style: preserve-3d;
-ms-transition: all 0.2s linear;
-o-transform-style: preserve-3d;
-o-transition: all 0.2s linear;
transition: all 0.2s linear;
z-index: 0;
}
#f1_container:hover #f1_card {
position: relative;
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
z-index: -10;
}
#f1_container:hover {
z-index: 10;
}
#f1_container:hover .front {
z-index: 0;
}
.face {
position: absolute;
width: 100%;
height: 100%;
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
-o-backface-visibility: hidden;
backface-visibility: hidden;
padding: 10px;
color: black;
}
.face.back {
position: absolute;
display: block;
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
box-sizing: border-box;
height: auto;
text-align: left;
background-color: lightblue;
color: white;
z-index: 20;
}
<div id="f1_container">
<div id="f1_card">
<div class="front face">
Front
</div>
<div class="back face center">
Back
</div>
</div>
</div>
答案 0 :(得分:0)
我从#f1_card中删除了背景颜色和边框样式,并将它们添加到.face.front
https://jsfiddle.net/af75qzqm/2/
.face.front {
background-color: #ffffff;
border: 3px solid transparent;
border-radius: 3px;
-webkit-box-shadow: 0 1px 1px #aaa;
}