The special effects produced by CSS combined with JavaScript further appreciate the powerful functions of CSS.
Dynamic style change
Let's take a look at a simple special effect. Here we only use properties and mouse events.
We use the "class" class attribute to change the document style.
Enlarge the text.
The code in this example is as follows:
| The code is as follows: |
Copy code |
<Html> <Head> <Title> change style </title> <Style> <! -- . Bigchange {color: blue; font-weight: bolder; font-size: 225%; Letter-spacing: 4px; background: yellow ;} // * Define the font color, width, size, font spacing, and background color of the bigchange class *// . Start {color: yellow; background: navy ;} // * Define the font color and background color of the start class *// --> </Style> </Head> <Body> <H1> dynamically change the style <P> move the cursor to the text on the blue background. </P> <P> we use the "class" class attribute to change the document style. <Span onmouseover = "this. className = 'bigchange '" Onmouseout = "this. classname = 'start'" class = "start" Style = "cursor: hand"> Enlarge the text. </Span> </p> </body> // * Defines the mouse trigger event. When you move the mouse up, the area is displayed in the bigchange type format, When the mouse leaves, use the start class to Display *// </Html>
|
This example is simple and easy to understand. I will not talk about it much.
| The code is as follows: |
Copy code |
<Html> <Head> <Title> change style </title> <Style> <! -- . Bigchange {color: blue; font-weight: bolder; font-size: 225%; Letter-spacing: 4px; background: yellow ;} // * Define the font color, width, size, font spacing, and background color of the bigchange class *// . Start {color: yellow; background: navy ;} // * Define the font color and background color of the start class *// --> </Style> </Head> <Body> <Span onmouseover = "this. className = 'bigchange '" Onmouseout = "this. classname = 'start'" class = "start" Style = "cursor: hand"> Enlarge the text. </Span> </p> </body> </Html> |
[Ctrl + A Select All tips: You can modify some code and then press run]