How to use an HTC file to encapsulate CSS styles

Source: Internet
Author: User

The following describes how to create an HTC instance by creating an HTC instance with the mouse sliding over and highlighted.

1. Create the HTC file architecture.

A standard HTC file contains a script block and a pair of optional component tags.
<Public: component>
<SCRIPT>
</SCRIPT>
</Public: component>

2. Write an executable script.
In the followingCodeAttach is used to set the message that the HTC receiving element is triggered in the onmouseover and onmouseout events. It notifies HTC to highlight the mouse over the element by switching the color.

<Public: component> <public: attach event = "onmouseover" onevent = "hilite ()"/> <public: attach event = "onmouseout" onevent = "Restore () "/> <script language =" jscript "> var normalcolor, normalspacing; function hilite () {// save original values normalcolor = runtimestyle. color; normalspacing = runtimestyle. letterspacing; runtimestyle. color = "red"; runtimestyle. letterspacing = 2;} function restore () {// Restore original values runtimestyle. color = normalcolor; runtimestyle. letterspacing = normalspacing ;}</SCRIPT> </public: component>

Save the above as the hilite. HTC file.

Note: You can directly access the attributes, methods, or event names without adding the element prefix.

In the previous example, we noticed that we directly called runtimestyle when switching colors, instead of using element. runtimestyle.

3. Once executed, HTC will be able to apply it on the webpage to achieve the effect of swiping and brightening the mouse.

    

mouse over the two list items below to see this effect.

  • Xiao He's Boer
  • netsos.cnblogs.com
Related Article

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.