How to create a three-dimensional text effect with css3 conversion

I am looking to recreate such an effect using CSS 3D Transforms: 3D text

How do I achieve this? That's what i still have

body { perspective: 400px; transition: perspective 1s; } .grid { display: flex; justify-content: center; align-items: center; background-image: url("http://i.imgur.com/3ACizko.jpg"); background-size: cover; height: 400px; width: 400px; transform: rotateX(60deg); margin: 0 auto; transition: transform 1s; perspective: 400px; } .grid p { transition: transform 1s; transform: rotateX(-60deg); } 
 <div class="grid"> <p>Hello</p> </div> 

I thought that if I rotated the background surface 60 degrees and rotated the text 60 degrees, it would cancel the effect, but apparently not?

Anyway, thanks in advance.

+7
html css css3
source share
2 answers

Yes, the transform-style: preserve-3d method is used to solve your problem.

But the problem is that IE does not support this property

The way to make it work in IE is to use a pseudo-element on p

 .grid { font-size: 30px; position: relative; left: 100px; top: 200px; perspective: 200px; perspective-origin: 0% 50%; } .grid:after { content: ""; position: absolute; width: 300px; height: 200px; top: -100px; left: -100px; transform: rotateX(30deg); background-image: repeating-linear-gradient(0deg, transparent 0px, transparent 47px, black 47px, black 50px), repeating-linear-gradient(90deg, transparent 0px, transparent 47px, black 47px, black 50px); } 
 <p class="grid">Hello</p> 
+2
source share

After a little research, I'm sure I will post my own answer.

This effect can be achieved by using the transform-style property and setting it to preserve-3d . This will be set to the parent element (in this case -.grid). I also use transform-origin:bottom to raise text from inside the grid. Here is a snippet:

 body { perspective: 400px; transition: perspective 1s; } .grid { display: flex; justify-content: center; align-items: center; background-image: url("http://i.imgur.com/3ACizko.jpg"); background-size: cover; height: 400px; width: 400px; transform: rotateX(60deg); margin: 0 auto; transition: transform 1s; perspective: 400px; transform-style:preserve-3d; } .grid p { transition: transform 1s; transform-origin:bottom; transform: rotateX(-60deg); } 
 <div class="grid"> <p>Hello</p> </div> 
+1
source share

All Articles