圆形文本动画错误修复

Circle text animation bugfixing

我曾与 this tutorial 合作,并编写了以下代码:

Splitting();
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: monospace;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: grey;
}

.circle {
  transform-style: preserve-3d;
  animation: animate 8s linear infinite;
}

.circle .char {
  position: absolute;
  top: 0;
  left: 0;
  background: blue;
  color: red;
  font-size: 4em;
  padding: 5px 12px;
  border-top: 4px solid black;
  border-bottom: 4px solid black;
  transform-style: preserve-3d;
  transform-origin: center;
  transform: rotateY(calc(var(--char-index) * 12deg)) translateZ(250px);
}

@keyframes animate {
  0% {
    transform: perspective(1000px) rotateY(360deg) rotateX(15deg);
  }
  100% {
    transform: perspective(1000px) rotateY(0deg) rotateX(15deg);
  }
}
<script src="https://unpkg.com/splitting/dist/splitting.min.js"></script>

<div class="circle" data-splitting>
  Circle-Text-Animation-Effects-
</div>

不幸的是,我发现它不适用于 Chrome 和 Firefox。它们不显示曲率。我试图用 Autoprefixer 修复它,但没有帮助。有人知道如何解决这个问题吗?

它应该是这样的,以及它在 Safari 中的样子:

您的字母周围有一个额外的跨度,需要 transform-style: preserve-3d;

Splitting();
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: monospace;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: grey;
}

.circle {
  transform-style: preserve-3d;
  animation: animate 8s linear infinite;
}
/* added this */
.circle > span {
  transform-style: preserve-3d;
  display: block;
}
/**/
.circle .char {
  position: absolute;
  top: 0;
  left: 0;
  background: blue;
  color: red;
  font-size: 4em;
  padding: 5px 12px;
  border-top: 4px solid black;
  border-bottom: 4px solid black;
  transform-style: preserve-3d;
  transform-origin: center;
  transform: rotateY(calc(var(--char-index) * 12deg)) translateZ(250px);
}

@keyframes animate {
  0% {
    transform: perspective(1000px) rotateY(360deg) rotateX(15deg);
  }
  100% {
    transform: perspective(1000px) rotateY(0deg) rotateX(15deg);
  }
}
<script src="https://unpkg.com/splitting/dist/splitting.min.js"></script>

<div class="circle" data-splitting>
  Circle-Text-Animation-Effects-
</div>