圆形文本动画错误交易

发布于 2025-01-23 15:04:44 字数 1733 浏览 2 评论 0原文

我与此教程,并对此进行了编码:

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无法使用。他们没有显示曲率。我试图用 autopreefixer ,但这无济于事。有没有人知道如何解决这个问题?

这是它的外观以及Safari的外观:

I worked with this tutorial, and coded this:

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>

Unfortunately, I realized that it doesn't work with Chrome and Firefox. They don't show the curvature. I tried to fix it with Autoprefixer, but it didn't help. Has anyone an idea how to solve this issue?

Here is how it should look like, and how it looks like with Safari:
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

若无相欠,怎会相见 2025-01-30 15:04:44

您的字母周围需要具有转换风格的额外跨度: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>

There is an extra span around your letters that need to have 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>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文