HTML中的卡片翻转程序无法正确翻转



链接到卡片翻转程序!

卡确实被翻转了,但是当它翻转时,会出现一瞬间的错误,该错误会立即消失。我应该如何删除该错误? 我想错误主要发生在背面可见性:隐藏时;被使用。

*{margin:0px; padding:0px;
}
body{
  background:#000;
}
.wrapper{
  margin:11% 32%;
  position:relative;
  border:5px solid black;
  width:390px;
  height:360px;
  perspective:800px;/*If u add some perspective to the container*/
}
.card{
  width:100%;
  height:100%;
  position:absolute;
  transition:-webkit-transform .7s cubic-bezier(0.175,0.885,0.320,1.275);/*Cubic ease giving a spring to it*/
  transform-style:preserve-3d;/*2Settings...one show child elements as 3d and other as flat...so just make it always on*/
}
.card:hover{
  -webkit-transform:rotateY(-180deg); /*When hovered it card flips*/
} 
h2,h3{
  font-family:"Arial Black", Gadget, sans-serif;
  font-weight:300;
  color:white;
  text-transform:uppercase;
}
p{
  color:white;
}
.front{
  border:15px solid white;
  text-align:center;
  width:360px;
  height:330px;
  position:absolute;
  backface-visibility:hidden; /*I dont wanna see your back*/
}
.back{
  border:15px solid red;
  text-align:center;
  font-weight:400;
  width:360px;
  height:330px;
  position:absolute;/*We dont want block ar something, we want right inside div where it was supposed to be without considering other elements*/
  backface-visibility:hidden;/*I dont wanna see your back*/
  -webkit-transform:rotateY(180deg);/**/
}
h2,.back{ 
  background: #F00943;
}
h3{
  text-align:left;
}
h2{ 
  background:rgba(240, 9, 67, 0.8);
  position: relative;
  top:-80px;
  padding:10px;
  width:350px;
  left:-5px;
}
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
  <body>
    <div class="wrapper"> <!--Front & back are inside Card,Card is inside the Wrapper-->
      <div class="card">
        <div class="front">
          <img src="http://www.dailybackgrounds.com/wp-content/uploads/2013/07/cute-cat-hd-image.jpg" height="330px" width="360px"/>
          <h2>Miss Mittens</h2>
        </div>
        <div class="back"><br/><br/><br/>
          <h3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Loves:</h3><br/>
          <p>Strings, cuddles, and <br/>long naps in the sun.</p><br/>
          <h3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dislikes:</h3><br/>
          <p>Bath, things that aren't sparkly and <br/>anything reassembling work.</p>
        </div>
      </div>
    </div>
  </body>
</html>

transform: rotateY(0deg) rotateZ(0deg) rotateX(0deg);添加到.front

在这里演示

* {
  margin: 0px;
  padding: 0px;
}
body {
  background: #000;
}
/*SeaseOutBack:cubic-bezier(0.175,0.885,0.320,1.275);*/
.wrapper {
  margin: 11% 32%;
  position: relative;
  border: 5px solid black;
  width: 390px;
  height: 360px;
  perspective: 800px;
  /*If u add some perspective to the container*/
}
.card {
  width: 100%;
  height: 100%;
  position: absolute;
  transition: -webkit-transform .7s cubic-bezier(0.175, 0.885, 0.320, 1.275);
  /*Cubic ease giving a spring to it*/
  transform-style: preserve-3d;
  /*2Settings...one show child elements as 3d and other as flat...so just make it always on*/
}
.card:hover {
  -webkit-transform: rotateY(-180deg);
}
h2,
h3 {
  font-family: "Arial Black", Gadget, sans-serif;
  font-weight: 300;
  color: white;
  text-transform: uppercase;
}
p {
  color: white;
}
.front {
  border: 15px solid white;
  text-align: center;
  width: 360px;
  height: 330px;
  position: absolute;
  backface-visibility: hidden;
  transform: rotateY(0deg) rotateZ(0deg) rotateX(0deg);
}
.back {
  border: 15px solid red;
  text-align: center;
  font-weight: 400;
  width: 360px;
  height: 330px;
  position: absolute;
  backface-visibility: hidden;
  transform: rotateY(180deg);
}
h2,
.back {
  background: #F00943;
}
h3 {
  text-align: left;
}
h2 {
  background: rgba(240, 9, 67, 0.8);
  position: relative;
  top: -80px;
  padding: 10px;
  width: 350px;
  left: -5px;
}
<div class="wrapper">
  <!--Front & back are inside Card,Card is inside the Wrapper-->
  <div class="card">
    <div class="front">
      <img src="http://www.dailybackgrounds.com/wp-content/uploads/2013/07/cute-cat-hd-image.jpg" height="330px" width="360px" />
      <h2>Miss Mittens</h2>
    </div>
    <div class="back">
      <br/>
      <br/>
      <br/>
      <h3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Loves:</h3>
      <br/>
      <p>Strings, cuddles, and
        <br/>long naps in the sun.</p>
      <br/>
      <h3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dislikes:</h3>
      <br/>
      <p>Bath, things that aren't sparkly and
        <br/>anything reassembling work.</p>
    </div>
  </div>
</div>

注意:在Chrome中经过测试并工作,在代码笔版本中,我打开了自动前缀器,因此您必须手动将其放入代码中。

最新更新