HTML5 page effect text effects how to implement it

Source: Internet
Author: User

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:

  1. <div class= "foo" >

  2. <span class= "letter" data-letter= "A" >A</span>

  3. <span class= "letter" data-letter= "B" >B</span>

  4. <span class= "letter" data-letter= "C" >C</span>

  5. <span class= "letter" data-letter= "D" >D</span>

  6. <span class= "letter" data-letter= "E" >E</span>

  7. <span class= "letter" data-letter= "F" >F</span>

  8. <span class= "letter" data-letter= "G" >G</span>

  9. <span class= "letter" data-letter= "H" >H</span>

  10. <span class= "letter" data-letter= "I" >I</span>

  11. <span class= "letter" data-letter= "L" >L</span>

  12. <span class= "letter" data-letter= "M" >M</span>

  13. <span class= "letter" data-letter= "N" >N</span>

  14. <span class= "letter" data-letter= "O" >O</span>

  15. <span class= "letter" data-letter= "P" >P</span>

  16. <span class= "letter" data-letter= "Q" >Q</span>

  17. <span class= "letter" data-letter= "R" >R</span>

  18. <span class= "letter" data-letter= "S" >S</span>

  19. <span class= "letter" data-letter= "T" >T</span>

  20. <span class= "letter" data-letter= "U" >U</span>

  21. <span class= "letter" data-letter= "V" >V</span>

  22. <span class= "letter" data-letter= "Z" >Z</span>

  23. </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.

    1. . letter{

    2. Display:inline-block;

    3. font-weight:900;

    4. Font-size:8em;

    5. Margin:0.2em;

    6. position:relative;

    7. Color: #00B4F1;

    8. transform-style:preserve-3d;

    9. perspective:400;

    10. Z-index:1;

    11. }

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.

  1. . Letter:before,. letter:after{

  2. Position:absolute;

  3. Content:attr (Data-letter);

  4. Transform-origin:top left;

  5. top:0;

  6. left:0;

  7. }

  8. . Letter,. Letter:before,. letter:after{

  9. Transition:all 0.3s ease-in-out;

  10. }

  11. . letter:before{

  12. Color: #fff;

  13. Text-shadow:

  14. -1px 0px 1px rgba (255,255,255,.8),

  15. 1px 0px 1px rgba (0,0,0,.8);

  16. Z-index:3;

  17. Transform

  18. Rotatex (0DEG)

  19. Rotatey ( -15DEG)

  20. Rotatez (0DEG);

  21. }

  22. . letter:after{

  23. Color:rgba (0,0,0,.11);

  24. Z-index:2;

  25. Transform

  26. Scale (1.08,1)

  27. Rotatex (0DEG)

  28. Rotatey (0DEG)

  29. Rotatez (0DEG)

  30. Skew (0DEG,1DEG);

  31. }

  32. . letter:hover:before{

  33. Color: #fafafa;

  34. Transform

  35. Rotatex (0DEG)

  36. Rotatey ( -40DEG)

  37. Rotatez (0DEG);

  38. }

  39. . letter:hover:after{

  40. Transform

  41. Scale (1.08,1)

  42. Rotatex (0DEG)

  43. Rotatey (40DEG)

  44. Rotatez (0DEG)

  45. Skew (0DEG,22DEG);

  46. }


  47. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.