HTML5 Page effect text effects how to implement it, before the online to see a more innovative HTML5 text effects, text effect is when the mouse is sliding over the effect of folding, similar to the book page. So I was very excited about the point of open source code to see a bit, found that the implementation is also quite simple, the main use of the CSS3 transform properties, respectively, the x-axis, y-axis, z-axis to flip, first look at the effect.
Look at these words is not very three-dimensional feeling, and this stereoscopic feeling is not with the projection and shadow to achieve, but by flipping.
Next we look at the source code. The first is the HTML code, very simple, listing the text we need to render:
<div class= "foo" >
<span class= "letter" data-letter= "A" >A</span>
<span class= "letter" data-letter= "B" >B</span>
<span class= "letter" data-letter= "C" >C</span>
<span class= "letter" data-letter= "D" >D</span>
<span class= "letter" data-letter= "E" >E</span>
<span class= "letter" data-letter= "F" >F</span>
<span class= "letter" data-letter= "G" >G</span>
<span class= "letter" data-letter= "H" >H</span>
<span class= "letter" data-letter= "I" >I</span>
<span class= "letter" data-letter= "L" >L</span>
<span class= "letter" data-letter= "M" >M</span>
<span class= "letter" data-letter= "N" >N</span>
<span class= "letter" data-letter= "O" >O</span>
<span class= "letter" data-letter= "P" >P</span>
<span class= "letter" data-letter= "Q" >Q</span>
<span class= "letter" data-letter= "R" >R</span>
<span class= "letter" data-letter= "S" >S</span>
<span class= "letter" data-letter= "T" >T</span>
<span class= "letter" data-letter= "U" >U</span>
<span class= "letter" data-letter= "V" >V</span>
<span class= "letter" data-letter= "Z" >Z</span>
</div>
Copy Code
Next is the core CSS3 code, where we omit the CSS code that controls the page style and extract the CSS code that implements the flip-out text.
. letter{
Display:inline-block;
font-weight:900;
Font-size:8em;
Margin:0.2em;
position:relative;
Color: #00B4F1;
transform-style:preserve-3d;
perspective:400;
Z-index:1;
}
Copy Code
So we let these letters in a quiet arrangement, and have their own background color, waiting for the powerful CSS3 to render.
Next we want the text to be flipped over the mouse to produce a flip-tilt animation.
. Letter:before,. letter:after{
Position:absolute;
Content:attr (Data-letter);
Transform-origin:top left;
top:0;
left:0;
}
. Letter,. Letter:before,. letter:after{
Transition:all 0.3s ease-in-out;
}
. letter:before{
Color: #fff;
Text-shadow:
-1px 0px 1px rgba (255,255,255,.8),
1px 0px 1px rgba (0,0,0,.8);
Z-index:3;
Transform
Rotatex (0DEG)
Rotatey ( -15DEG)
Rotatez (0DEG);
}
. letter:after{
Color:rgba (0,0,0,.11);
Z-index:2;
Transform
Scale (1.08,1)
Rotatex (0DEG)
Rotatey (0DEG)
Rotatez (0DEG)
Skew (0DEG,1DEG);
}
. letter:hover:before{
Color: #fafafa;
Transform
Rotatex (0DEG)
Rotatey ( -40DEG)
Rotatez (0DEG);
}
. letter:hover:after{
Transform
Scale (1.08,1)
Rotatex (0DEG)
Rotatey (40DEG)
Rotatez (0DEG)
Skew (0DEG,22DEG);
}
Copy Code
Copy Code
Here we use CSS3 's pseudo-class before and after to quickly construct two identical letters, then flip through the Rotatex,rotatey,rotatez of the Transform property, and then use the skew to skew the text.
Article Source: There is a recruit network reprint please indicate the source article link: http://www.youjobit.com/news_108.html