Is it possible to achieve perspective with 3d transforms on a SVG elements?
I'm talking about something similar with how the Star Wars opening titles look like with 3d perspective. This is a jsfiddle with the desired effect achieved using CSS3 3d transforms:
<section style="transform: perspective(200px) rotateX(-30deg); transform-origin: 50% 100%; text-align: justify; width: 100px;">
<p style="backface-visibility: hidden;">TEXTTEXTTEXT</p>
</section>
Update Nov 2018:
Testing the snipet from the question in latest chrome and Firefox works. Although support for 3d transforms on svg elements isn't very wide, browsers are implementing it more and more.
Origin answer :
3D transforms aren't supported on SVG elements. There are a few workarounds though :
If the svg doesn't contain elements that shouldn't be transformed, you can use CSS 3d transforms on the SVG element itself :
In case of polygons, you make a 2D polygon look like a 3D polygon. In the following example, the red rectangle is 3D rotated (
rotateX(40deg)
) and the black rectangle is a 2D SVG polygon made to look like a 3D rotated rectangle:3D transforms are supported inside
<svg>
elements (f.e. on<circle>
) (at least to some extent, it seems like perspective is isometric only).For example, here's animation of
transform: rotate3d
applied to<circle>
elements (tested in Chrome only):Also available here: https://codepen.io/anon/pen/MPeyEj