InWhen browsing, the page displays an almost transparent image. When you move the mouse over the image, the image gradually becomes clearer. When you move the mouse away, the image is restored to the original transparent State. To implement this function, you need to use the Alpha filter of CSS and use JavaScript to control the opacity value of the Alpha filter. First, insert an image into the webpage and set the opacity value of the Alpha filter, make the image transparent and add onmouseover and onmouseout actions to the image.
JavaScript code
Function Cssfilter (N)
{
If (N = " Add " ) // If the input parameter is add, the opacity of the image is increased.
If (IMG. Filters. Alpha. Opacity < 100 )
{
IMG. Filters. Alpha. Opacity + = 5 ;
SetTimeout ( " Cssfilter ('add ') " , 20 );
}
If (N = " Dec " ) // If the input parameter is Dec, the opacity of the image is reduced.
If (IMG. Filters. Alpha. Opacity > 20 )
{
IMG. Filters. Alpha. Opacity -= 5 ;
SetTimeout ( " Cssfilter ('dec ') " , 20 );
}
}
Foreground image HTML:
< IMG SRC = "Here is the image path" ID = "IMG" Style = "Filter: alpha (opacity = 20 )"
Onmouseover = "Cssfilter ('add ')" Onmouseout = "Cssfilter ('dec ')" />
// Reprinted the following content:
Share the following information:
CSS addition:Html{Filter:Progid: DXImageTransform. Microsoft. basicimage (grayscale = 1);}
Or:Html{Filter: Gray}
You can add it to the webpage, but the page is too large to be changed and CSS is convenient.
<Style.Type="Text/CSS">Html{Filter: Gray} </Style>
Sometimes it may not take effect because the website does not use the latest standard webpage protocol.
Add the following to the page:
<! Doctype HTML public"-// W3C // dtd xhtml 1.0 transitional // en""Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <HTML xmlns ="Http://www.w3.org/1999/xhtml">
The color of the Flash animation on the website cannot be controlled by the CSS Filter. You need to <object…> And </Object>:
<ParamValue="False"Name ="Menu"/> <ParamValue="Opaque"Name ="Wmode"/>
Basically, success... Http://www.cnblogs.com/sun8134/archive/2010/04/21/1716794.html