【问题标题】:Flip effect in Internet ExplorerInternet Explorer 中的翻转效果
【发布时间】:2016-05-13 23:37:11
【问题描述】:

我有一个代码可以翻转到一个 div。它在 Firefox 和 Chrome 中运行良好,但在 IE 中,当卡片翻转时,它会显示正面颠倒而不是显示背面。

这是代码:

body {
  background: #eee;
}

.card{
  width: 300px;
  height: 300px;
}

.content {
  width: 300px;
  height: 300px;
  perspective: 500px;
  box-shadow: 0 0 15px rgba(0,0,0,0.1);
  transition: transform 1s;
  transform-style: preserve-3d;
}

.card:hover .content {
  transform: rotateX( 180deg ) ;
  transition: transform 0.5s;
}

.front,
.back {
  position: absolute;
  height: 100%;
  width: 100%;
  background: white;
  line-height: 300px;
  color: #03446A;
  text-align: center;
  font-size: 60px;
  border-radius: 5px;
  backface-visibility: hidden;
  }

.back {
  background: #03446A;
  color: white;
  transform: rotateX( 180deg );
}
<div class="card">
   <div class="content">
     <div class="front">
        Front
     </div>
     <div class="back">
        Back!
     </div>
  </div>
</div>

【问题讨论】:

标签: html css flip


【解决方案1】:

正如 Shaggy 所说,IE 不支持 preserve-3d。它还缺乏对背面可见性的支持:隐藏;

所以,你不能旋转容器,你必须单独旋转元素。

并且您需要调整可见性(过渡时间的一半,您希望它发生在旋转中间。

这是结果,在现代浏览器和 IE 上都可以正常工作

body {
  background: #eee;
}

.card{
  width: 300px;
  height: 300px;
}

.content {
  width: 300px;
  height: 300px;
  perspective: 500px;
  box-shadow: 0 0 15px rgba(0,0,0,0.1);
  transition: transform 1s;
  transform-style: preserve-3d;
}

.card:hover .content {
}

.front,
.back {
  position: absolute;
  height: 100%;
  width: 100%;
  background: white;
  line-height: 300px;
  color: #03446A;
  text-align: center;
  font-size: 60px;
  border-radius: 5px;
  backface-visibility: hidden;
  }


.front {
  transition: visibility 0.5s, transform 1s;
}

.card:hover .front {
  visibility: hidden;
  transform: rotateX(180deg);
}

.back {
  background: #03446A;
  color: white;
  transform: rotateX( -180deg );
  transition: visibility 0.5s, transform 1s;
}

.card:hover .back {
  transform: rotateX(0deg);
  
}
<div class="card">
   <div class="content">
     <div class="front">
        Front
     </div>
     <div class="back">
        Back!
     </div>
  </div>
</div>

【讨论】:

    猜你喜欢
    • 2016-12-29
    • 1970-01-01
    • 2014-12-08
    • 2015-02-28
    • 2010-10-04
    • 2016-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多