Control the transparent properties of the Div layer, gradually display from shap to deep, and gradually disappear from deep to shap. The specific implementation code is as follows. If you like it, you can feel it and keep it for yourself!
Copy the following blue code and save it as an html file.
The Code supports IE6, 7, 8, firefox, and Chrome browsers.
The Code is as follows:
Javascript controls the transparent attributes of the Div layer, and gradually displays the transparent attributes from shap to deep, gradually disappears from deep to shap.
Script
Var SysIsIE;
Var ua = navigator. userAgent. toLowerCase ();
Var s; (s = ua. match (/msie ([\ d.] + )/))? SysIsIE = s [1]: 0;
Function Q (s ){
Return document. getElementById (s );
}
Function dvck (){
Idstr = 'tiany ';
E = Q (idstr );
If (e ){
E. parentNode. removeChild (e );
}
Var p = document. createElement ("p ");
P. style. position = "absolute ";
P. style. top = '123 ';
P. style. left = '20140901 ';
P.style.css Text = 'filter: alpha (opacity = 10); opacity: 0.1; position: absolute; top: 50%; left: 50%; width: 544px; height: 354px; margin-top:-177px; margin-left:-272px; background-color: #000 ';
P. id = idstr;
// P. innerHTML = '';
P. innerHTML ='
Content displayed on the p layer, author: bluid
Close
';
Document. body. appendChild (p );
If (SysIsIE)
DcbIE (idstr, '+ ');
Else
Dcboth (idstr, '+ ');
}
Function dcbIE (s, j ){
O = Q (s );
Opc = parseInt (o. filters. alpha. opacity );
If (j = '+ '){
If (opc <100 ){
O. filters. alpha. opacity = (opc + 10) + '';
SetTimeout ("dcbIE ('" + s + "', '" + j + "')", 100 );
}
} Else if (j = '-'){
If (opc> 0 ){
O. filters. alpha. opacity = (opc-10) + '';
SetTimeout ("cleand ('" + s + "', '" + j + "')", 100 );
}
}
}
Function dcboth (s, j ){
O = Q (s );
Opc = parseFloat (o. style. opacity );
If (j = '+ '){
If (opc <1 ){
O. style. opacity = (opc + 0.1) + '';
// SetInterval ("dcboth ('" + s + "')", 3000 );
SetTimeout ("dcboth ('" + s + "', '" + j + "')", 100 );
}
} Else if (j = '-'){
If (opc> 0 ){
O. style. opacity = (opc-0.1) + '';
SetTimeout ("cleand ('" + s + "', '" + j + "')", 100 );
}
}
}
Function cleand (s ){
If (SysIsIE ){
DcbIE (s ,'-');
} Else {
Dcboth (s ,'-');
}
}
Script
Javascript controls the transparent attributes of the Div layer, and gradually displays the transparent attributes from shallow to deep, and gradually disappears from deep to light.
Click 'click' to display the layer.
Click
Click on the displayed layer to gradually disappear from deep to light
02/11/2011 16: 17 --- Author: bluid