最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

html - 3D vertical flip animation on a div with a different backside? - Stack Overflow

programmeradmin3浏览0评论

I am basically trying to replicate an effect from a website (Awwwards link) where there seems to be a grid of divs that individually "flip" vertically on-hover and all together on-scroll.

There also seems to have a subtle effect once the card flips back similar to how a Framer Spring looks like.

On inspection, the website uses threejs, lenis, and swup, but I'm not sure whether it actually uses threejs for that particular section.

This is as far as I have tried to do it in just CSS, which I could put multiple of in a grid:

body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  margin: 0;
  font-family: Arial, sans-serif;
}

.flip-card {
  width: 200px;
  height: 120px;
  perspective: 1000px;
  cursor: pointer;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}

.flip-card:hover .flip-card-inner {
  transform: rotateX(180deg);
}

.flip-card-front, .flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  backface-visibility: hidden;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.flip-card-front {
  background-color: dodgerblue;
  color: white;
}

.flip-card-back {
  background-color: #2980b9;
  color: white;
  transform: rotateX(180deg);
}
<div class="flip-card">
  <div class="flip-card-inner">
    <div class="flip-card-front">
      <p>Front</p>
    </div>
    <div class="flip-card-back">
      <p>Back</p>
    </div>
  </div>
</div>
发布评论

评论列表(0)

  1. 暂无评论