
Normally, if you want to rotate or scale from the center of an element, you’d set transform-origin: 50% 50%. Think of the transform-origin as the point around which all rotating and scaling occurs, as if a pin was holding it in place there, Where’s my transform-origin? In all browsers, px-based origins are measured differently for SVG elements than other DOM elements (see below).Firefox doesn’t recognize keyword-based origins like "right bottom", and Safari alters them when the zoom is anything but 100%.Zooming in Safari breaks the sync between %-based and px-based origins.Instead, you must assign the value to the transform attribute.
IE and Opera don’t honor CSS transforms at all on SVG elements. See the Pen GIFS: SVG + CSS Transform Problems by GreenSock ( on CodePen. Browser bugs & inconsistenciesįirst, check out these animated GIFs showing the exact same CSS animation of two elements in various browsers (at least as of November 2014): In this article, I’ll walk you through some of the problems and then show you a technique that harmonizes behavior across browsers and is baked into the latest version of the GreenSock Animation Platform ( GSAP). But don’t worry this complicated love story has a happy ending. This is particularly painful when it comes to animation because scale, position, rotation, and skew are so fundamental.īuckle up, because we’re in for a bumpy ride. SVG is all the rage these days, and browser support is generally excellent…with one glaring exception: CSS transforms. This time, he focuses on SVG animation, some pretty scary issues you may come across while manipulating them with CSS, and how you can solve those issues.
He’s written here before, talking about how JavaScript animation can be the most performant choice (Google even recommends it). Jack has been deep in the woods of web animation for a long time, trying to make it easier and better. The following is a guest post by Jack Doyle, author of the GreenSock Animation Platform (GSAP).