CSS3 pseudo-class Nth-child combined with Transiton animation to achieve the text if the shadow of the present

Source: Internet
Author: User

CSS3 pseudo-class Nth-child combined with Transiton animation to achieve the text if the shadow of the present
To create a div box and then wrap it in a div with 10 span tags, fill in the contents of each span tag once for A,B,C,D,E,F,G,H,I,,J
First look at the following:

See HTML5 Code:

  1. <div class= "box" >
  2. <span>A</span>
  3. <span>B</span>
  4. <span>C</span>
  5. <span>D</span>
  6. <span>E</span>
  7. <span>F</span>
  8. <span>G</span>
  9. <span>H</span>
  10. <span>I</span>
  11. <span>J</span>
  12. </div>
Copy Code

Next, add some CSS styles to the div:

  1. . box {
  2. Background-image:linear-gradient (135deg, #723362, #9d223c);
  3. Color: #fff;
  4. Padding:1em 0;
  5. Text-align:center;
  6. font-weight:300;
  7. Text-transform:uppercase;
  8. Letter-spacing:. 4em;
  9. Padding-left:. 4em;
  10. Font-size:1.8em;
  11. Margin-top:2.5rem
  12. }
Copy Code

One thing to say here is linear-gradient (,,,)
A total of three parameters, the first parameter represents the direction of the linear gradient, top is from top to bottom, left is from Ieft to right, if it is defined as left top, it is from the upper right corner to the bottom of the bottom. This defines an angle of 135 degrees, and the second and third parameters are the starting and ending colors, respectively.
Then the background role is set to #9d223c
The text is white, and the center display, the text bold display, where text-transform:uppercase represents the text is only in the beginning of the capital letter rotation, and some of the others do not have to say that are common some of the properties of what the margin outside AH font size AH and so on.

The following is the Real Entry topic section:
Look at the following code:

  1. . box1 span {opacity:0;transition:opacity 1300ms}
  2. . box:hover span {opacity:1}
  3. . Box Span:nth-child (1) {transition-delay:200ms}
  4. . Box Span:nth-child (2) {transition-delay:1200ms}
  5. . Box Span:nth-child (3) {transition-delay:800ms}
  6. . Box Span:nth-child (4) {transition-delay:300ms}
  7. . Box Span:nth-child (5) {transition-delay:700ms}
  8. . Box Span:nth-child (6) {transition-delay:600ms}
  9. . Box Span:nth-child (7) {transition-delay:400ms}
  10. . Box Span:nth-child (8) {transition-delay:900ms}
  11. . Box Span:nth-child (9) {transition-delay:700ms}
  12. . Box Span:nth-child (Ten) {transition-delay:50ms}
Copy Code

After setting up the CSS style of the DIV, we must first hide the contents of the span element under the DIV or make him transparent, and opacity:0 is transparent if the value set to 1 is opaque. Of course you can also set to 0.5 or 0.3 and so on, the value of opacity is between 0 and 1.
After the initialization setting is 0 transparent, we need to display the opacity when we hover over the span element so we need to change the transparency to 1.

Transition animation over-effect specific use of the method, see http://www.00h5.com/thread-15-1-1.html
Where Transition-delay is the last property of transition indicates when the animation is over when it starts
Look again: Nth-child, pseudo class selector.
So what is pseudo-class?
Pseudo-Class See http://www.00h5.com/thread-76-1-1.html Here we use: Nth-child to select the set span element content effect transition, set the appearance of each span and vanishing time to achieve the effect.
Final complete code:

  1. <! DOCTYPE html>
  2. <meta charset= "UTF-8" >
  3. <title>transition</title>
  4. <style>
  5. . box {
  6. Background-image:linear-gradient (135deg, #723362, #9d223c);
  7. Color: #fff;
  8. Padding:1em 0;
  9. Text-align:center;
  10. font-weight:300;
  11. Text-transform:uppercase;
  12. Letter-spacing:. 4em;
  13. Padding-left:. 4em;
  14. Font-size:1.8em;
  15. Margin-top:2.5rem
  16. }
  17. . Box span {opacity:0;transition:opacity 1300ms}
  18. . Box Span:nth-child (1) {transition-delay:200ms}
  19. . Box Span:nth-child (2) {transition-delay:1200ms}
  20. . Box Span:nth-child (3) {transition-delay:800ms}
  21. . Box Span:nth-child (4) {transition-delay:300ms}
  22. . Box Span:nth-child (5) {transition-delay:700ms}
  23. . Box Span:nth-child (6) {transition-delay:600ms}
  24. . Box Span:nth-child (7) {transition-delay:400ms}
  25. . Box Span:nth-child (8) {transition-delay:900ms}
  26. . Box Span:nth-child (9) {transition-delay:700ms}
  27. . Box Span:nth-child (Ten) {transition-delay:50ms}
  28. . box:hover span {opacity:1}
  29. </style>
  30. <body>
  31. <div class= "box" >
  32. <span>A</span>
  33. <span>B</span>
  34. <span>C</span>
  35. <span>D</span>
  36. <span>E</span>
  37. <span>F</span>
  38. <span>G</span>
  39. <span>H</span>
  40. <span>I</span>
  41. <span>J</span>
  42. </div>
  43. </body>
Transfer from 00 h5http://www.00h5.com/thread-676-1-1.html

CSS3 pseudo-class Nth-child combined with Transiton animation to achieve the text if the shadow of the present

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.