CSS dynamic style change

Source: Internet
Author: User

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]

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.