如何在iOS11和macOS10.12 Safari上修复损坏的transform-origin?

kum*_*uma 5 css safari ios css-animations

我正在尝试使用svg实现CSS动画.
我期待2个svg盒子旋转(旋转)transform-origin: center center;360度.看起来它的行为与我对Chrome和Firefox的预期相似,但与macOS 10.12(High Sierra)和iOS 11.0.x以及11.1 beta Safari无关.
好像transform-origin: center center;在Safari中不起作用?

有什么方法可以解决这个问题吗?

我期待的是: 我所期待的

我在Safari上看到的内容: 我在Safari上看到了什么

这是一个示例代码

HTML:

svg(width=500, height=500, viewBox='0 0 500 500')
  rect(x=100, y=100, width=50, height=100)
  rect(x=400, y=100, width=50, height=100)
Run Code Online (Sandbox Code Playgroud)

CSS:

@keyframes rotate {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

rect {
  transform-origin: center center;
  animation-duration: 3s;
  animation-name: rotate;
  animation-iteration-count: infinite;
  animation-timing-function: linear;

  &:nth-child(1) {
    fill: red;
  }

  &:nth-child(2) {
    fill: blue;
  }
}
Run Code Online (Sandbox Code Playgroud)

您可以通过访问Chrome和Safari来查看此处的行为:https: //codepen.io/manaten/pen/aLeXjW

编辑:

https://codepen.io/manaten/pen/aVzeEK 问题的另一个例子.看起来origin被设置为Safari的svg元素的中心.

Mic*_*ber 1

变换框:填充框;似乎解决了问题。

rect {
  transform-origin: center center;
  transform-box: fill-box;
  animation-duration: 3s;
  animation-name: rotate;
  animation-iteration-count: infinite;
  animation-timing-function: linear;

  &:nth-child(1) {
    fill: red;
  }

  &:nth-child(2) {
    fill: blue;
  }
}
Run Code Online (Sandbox Code Playgroud)

您的第一个带有转换框的示例:

https://codepen.io/MichaelSchober/pen/QOPbKx

适用于 MacOs HighSierra 10.13.1 和 Safari 11.0.1

该属性仍处于实验阶段。因此,请务必检查浏览器兼容性是否合适:

https://developer.mozilla.org/de/docs/Web/CSS/transform-b​​ox