我正在使用以下 CSS 使用 CSS3 进行翻转过渡:
/* simple */
.flip-container {
-webkit-perspective: 1000;
-moz-perspective: 1000;
perspective: 1000;
-webkit-box-shadow: 1px 1px 1px 1px #ccc;
-moz-box-shadow: 1px 1px 1px 1px #ccc;
box-shadow: 1px 1px 1px 1px #ccc;
border: 1px solid #fff;
}
.flip-container:hover .flipper, .flip-container.hover .flipper {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.flip-container, .front, .back {
width: 160px;
height: 160px;
}
.flipper {
-webkit-transition: 0.6s;
-webkit-transform-style: preserve-3d;
-moz-transition: 0.6s;
-moz-transform-style: preserve-3d;
transition: 0.6s;
transform-style: preserve-3d;
position: relative;
}
.front, .back {
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
}
.front {
z-index: 2;
text-align: center;
}
.back {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.front .name {
font-size: 2em;
display: inline-block;
background: rgba(33, 33, 33, 0.9);
color: #f8f8f8;
font-family: Courier;
padding: 5px 10px;
border-radius: 5px;
bottom: 60px;
left: 25%;
position: absolute;
text-shadow: 0.1em 0.1em 0.05em #333;
-webkit-transform: rotate(-20deg);
-moz-transform: rotate(-20deg);
transform: rotate(-20deg);
}
.back-logo {
position: absolute;
top: 40px;
left: 90px;
width: 160px;
height: 117px;
background: url(logo.png) 0 0 no-repeat;
}
.back-title {
font-weight: bold;
color: #00304a;
position: absolute;
top: 180px;
left: 0;
right: 0;
text-align: center;
text-shadow: 0.1em 0.1em 0.05em #acd7e5;
font-family: Courier;
font-size: 2em;
}
.back p {
position: absolute;
bottom: 40px;
left: 0;
right: 0;
text-align: center;
padding: 0 20px;
}
CSS的实现如下:
<div class="sidepanel" id="troll">
<div class="flip-container" ontouchstart="this.classList.toggle('hover');">
<div class="flipper">
<a href="../articlenew/troll.php?id=<?php echo rand(1,$maxnum);?>"><div class="front" >
<span style="font-size: 26px; color:#333;">The Best Thing in this World is</span><br />
<strong style="font-size: 40px; color:red;">SE...</strong></div></a>
<a href="../articlenew/troll.php?id=<?php echo rand(1,$maxnum);?>"><div class="back" style="text-align:center; color:#333;">
<!-- back content -->
<span style="font-size: 30px">Secrets!</span>
<img src="../trial/youmad.png" width="70" height="70" /><br />
<span style="font-size: 20px">You Mad?</span><br />
<span style="font-size: 16px">Best College Trolls</span> </div></a>
</div>
</div>
问题是在某些浏览器中它工作正常,在某些浏览器中,我看到前面的文本以及后面的文本反转,就像当一个人在镜子中看到一个文本时一样。我不知道它在哪里搞砸了。我确实考虑过浏览器版本和兼容性,但我认为 HTML5 和 CSS3 现在已经足够流行,所有浏览器都支持它们。我还分享了一些图片来解释: