css翻转动画

鼠标经过翻转卡片显示不同内容

920 发布: 2024/9/10 10:10 本文总阅读量
卡片翻转
<div class="card-filp">
    <div class="back"></div>
    <div class="front"></div>
</div>

<style>
  .card-filp {
    height: 200px;
    width: 200px;
    position: relative;
    transform-style: preserve-3d;
    transition: 1s;
  }

  .front,
  .back {
    height: 100%;
    width: 100%;
    position: absolute;
    left: 0;
    top: 0;
    backface-visibility:hidden
  }
  .front {
    background: lightgreen;
  }
  .back {
    background: lightblue;
  }
  .back {
    transform: rotateY(180deg);
  }
  .card-filp:hover {
    transform: rotateY(180deg);
  }
</style>

原文地址