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:
- <div class= "box" >
- <span>A</span>
- <span>B</span>
- <span>C</span>
- <span>D</span>
- <span>E</span>
- <span>F</span>
- <span>G</span>
- <span>H</span>
- <span>I</span>
- <span>J</span>
- </div>
Copy Code
Next, add some CSS styles to the div:
- . box {
- Background-image:linear-gradient (135deg, #723362, #9d223c);
- Color: #fff;
- Padding:1em 0;
- Text-align:center;
- font-weight:300;
- Text-transform:uppercase;
- Letter-spacing:. 4em;
- Padding-left:. 4em;
- Font-size:1.8em;
- Margin-top:2.5rem
- }
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:
- . box1 span {opacity:0;transition:opacity 1300ms}
- . box:hover span {opacity:1}
- . Box Span:nth-child (1) {transition-delay:200ms}
- . Box Span:nth-child (2) {transition-delay:1200ms}
- . Box Span:nth-child (3) {transition-delay:800ms}
- . Box Span:nth-child (4) {transition-delay:300ms}
- . Box Span:nth-child (5) {transition-delay:700ms}
- . Box Span:nth-child (6) {transition-delay:600ms}
- . Box Span:nth-child (7) {transition-delay:400ms}
- . Box Span:nth-child (8) {transition-delay:900ms}
- . Box Span:nth-child (9) {transition-delay:700ms}
- . 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:
- <! DOCTYPE html>
- <meta charset= "UTF-8" >
- <title>transition</title>
- <style>
- . box {
- Background-image:linear-gradient (135deg, #723362, #9d223c);
- Color: #fff;
- Padding:1em 0;
- Text-align:center;
- font-weight:300;
- Text-transform:uppercase;
- Letter-spacing:. 4em;
- Padding-left:. 4em;
- Font-size:1.8em;
- Margin-top:2.5rem
- }
- . Box span {opacity:0;transition:opacity 1300ms}
- . Box Span:nth-child (1) {transition-delay:200ms}
- . Box Span:nth-child (2) {transition-delay:1200ms}
- . Box Span:nth-child (3) {transition-delay:800ms}
- . Box Span:nth-child (4) {transition-delay:300ms}
- . Box Span:nth-child (5) {transition-delay:700ms}
- . Box Span:nth-child (6) {transition-delay:600ms}
- . Box Span:nth-child (7) {transition-delay:400ms}
- . Box Span:nth-child (8) {transition-delay:900ms}
- . Box Span:nth-child (9) {transition-delay:700ms}
- . Box Span:nth-child (Ten) {transition-delay:50ms}
- . box:hover span {opacity:1}
- </style>
- <body>
- <div class= "box" >
- <span>A</span>
- <span>B</span>
- <span>C</span>
- <span>D</span>
- <span>E</span>
- <span>F</span>
- <span>G</span>
- <span>H</span>
- <span>I</span>
- <span>J</span>
- </div>
- </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