css - Safari 问题中的动画文本对齐更改

标签 css animation safari

我使用 CSS 关键帧和动画来设置 text-align 的动画,但此属性的动画不会在 Safari 中“播放”,但文本的颜色会发生变化。

div {
  width: 200px;
  height: 200px;
  border: 1px solid #000;
  animation: ani 5s 1 both linear;
}

@keyframes ani {
  0% {
    text-align: right;
    color: red;
  }
  50% {
    text-align: center;
    color: blue;
    text-decoration: underline;
  }
  100% {
    color: green;
  }
}
<div>
abcd
</div>

codesandbox

也许这是 Safari 的一个错误,因为我可以将 text-align: center 设置为 div。

最佳答案

试试这个。 browser prefix 会帮助你。经过测试的 Safari 5.1.7

    .abcz {
  width: 200px;
  height: 200px;
  border: 1px solid #000;
  -webkit-animation: ani 5s 1 both linear;
          animation: ani 5s 1 both linear;
}

@-webkit-keyframes ani {
  0% {
    text-align: right;
    color: red;
  }
  50% {
    text-align: center;
    text-align: -webkit-center;
    color: blue;
    text-decoration: underline;
  }
  100% {
    color: green;
  }
}

@keyframes ani {
  0% {
    text-align: right;
    color: red;
  }
  50% {
    text-align: center;
    text-align: -webkit-center;
    color: blue;
    text-decoration: underline;
  }
  100% {
    color: green;
  }
}
<div class="abcz">
abcd
</div>

关于css - Safari 问题中的动画文本对齐更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58709832/

相关文章:

javascript - 如何通过滚动动画 CSS 过渡效果?

ios - “order”(bootstrap 4 网格)在 Safari IOS 中无法正常工作

javascript - jQuery - 如何检测剪贴板内容是否已更改?

javascript - 在 jQuery 中进行宽度转换

CSS z-index 不适用于相对位置

wpf - 动画从 LinearGradientBrush 更改为 SolidColorBrush

swift - 以编程方式删除 Safari cookie

javascript - Jquery javascript 无法在 Safari 5 上运行

html - 为什么不定位: sticky work on my header?

javascript - 简单的下拉菜单按钮