Use CSS to implement mouse-click Special Effects

Source: Internet
Author: User

If you can apply CSS well, your homepage will be well dressed. Next we will introduce you to the special style of clicking with a mouse in CSS.

1. Set the followingCodeCopy to and between your home page.

<Style>. Shadow {
Filter: Shadow (color = blue, direction = 225)
}
. Shadow1 {
Filter: Shadow (color = Red, direction = 225)
}
. Shadow2 {
Filter: Shadow (color = green, direction = 225)
}
. Div {
Cursor: move; filter: blur (add = ture, direction = 135, strength = 10); width: 800px
}
</Style> 〉

Here the blur filter is applied.

2. Insert an image into the page. For example, if I insert an image in the format of "〉. Add <TD id = flttgt style = "filter: light (Enabled = 1), ''width 300'' "width = 315> 〉.

Add <TD style = "vertical-align: Top" width = 314> to the next line of the inserted image 〉

3. After setting the image attributes, we also need to apply the Javascript script code, that is, to make the image move some special effects with the mouse. The Code is as follows.

<Script language = JavaScript> 〉
<〈! --
VaR g_numlights = 0;
VaR blurbs = new array ("the current dynamic filter gives the webpage more interactivity to respond to user actions. "," We use a light source filter to respond to users' clicks. Click an image to add a light source. "," Move the light source by capturing the user's mouse position. "," Too much programming is not required. ");
Window. onload = setlights;
Document. onclick = keyhandler;
Flttgt. onmousemove = mousehandler;
Function setlights (){
Flttgt. Filters [0]. Clear ();
Flttgt. Filters [0]. addcone (5,100,100,225,225, 15 );
If (g_numlights> 0 ){
Flttgt. Filters [0]. addcone (400,170, 5,100,100,225 );
If (g_numlights> 1 ){
Flttgt. Filters [0]. addcone (320,330, 5,100,100, 0,225,225, 60, 15 );
}
}
}
Function keyhandler ()
{
G_numlights = (g_numlights + = 1) % 4;
Holder. innerhtml = blurbs [g_numlights];
Setlights ();
}
Function mousehandler ()
{
X = (window. event. x-80 );
Y = (window. event. y-80 );
Flttgt. Filters [0]. movelight (1, x, y, 5, 1 );
If (g_numlights> 0 ){
Flttgt. Filters [0]. movelight (1, x, y, 5, 1 );
If (g_numlights> 1)
{
Flttgt. Filters [0]. movelight (2, X, Y, 5, 1 );
}
}
}
</SCRIPT> 〉

In this way, you can set a special image effect.

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.