javascriptはDiv層の透明属性をコントロールして、浅いから深くなります.
3609 ワード
運ぶのは残してから自分で見てください.
下の青いコードをコピーしてhtml形式のファイルとして保存して、Webブラウザを使って効果をブラウズします.
コードサポートIE 6、7、8/firefox/Chromeブラウザ
下の青いコードをコピーしてhtml形式のファイルとして保存して、Webブラウザを使って効果をブラウズします.
コードサポートIE 6、7、8/firefox/Chromeブラウザ
javascript Div , ,
<br>var SysIsIE;
<br>var ua = navigator.userAgent.toLowerCase();
<br>var s;(s = ua.match(/msie ([\d.]+)/)) ? SysIsIE = s[1] : 0;
<br>
<br>function Q(s){
<br>return document.getElementById(s);
<br>}
<br>function dvck(){
<br>idstr='tian';
<br>e=Q(idstr);
<br>if(e){
<br>e.parentNode.removeChild(e);
<br>}
<br>var div=document.createElement("div");
<br>div.style.position="absolute";
<br>div.style.top='10%';
<br>div.style.left='40%';
<br>div.style.cssText='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';
<br>div.id=idstr;
<br>//div.innerHTML='<img src="i.jpg" onclick="cleand(\''+idstr+'\')" />';
<br>div.innerHTML='<p style="color:#fff;text-align:center;">div ,author:<a href="http://hi.baidu.com/bluid" style="color:#FBFC4D">bluid</a><br><br><br><br><br><a href="javascript:cleand(\''+idstr+'\')" style="color:#FEF8C3"> </a></p>';
<br>document.body.appendChild(div);
<br>if (SysIsIE)
<br>dcbIE(idstr,'+');
<br>else
<br>dcboth(idstr,'+');
<br>}
<br>function dcbIE(s,j){
<br>o=Q(s);
<br>opc=parseInt(o.filters.alpha.opacity);
<br>if(j=='+'){
<br>if(opc<100){
<br>o.filters.alpha.opacity=(opc+10)+'';
<br>setTimeout("dcbIE('"+s+"','"+j+"')",100);
<br>}
<br>}else if(j=='-'){
<br>if(opc>0){
<br>o.filters.alpha.opacity=(opc-10)+'';
<br>setTimeout("cleand('"+s+"','"+j+"')",100);
<br>}
<br>}
<br>}
<br>function dcboth(s,j){
<br>o=Q(s);
<br>opc=parseFloat(o.style.opacity);
<br>if(j=='+'){
<br>if(opc<1){
<br>o.style.opacity=(opc+0.1)+'';
<br>//setInterval("dcboth('"+s+"')",3000);
<br>setTimeout("dcboth('"+s+"','"+j+"')",100);
<br>}
<br>}else if(j=='-'){
<br>if(opc>0){
<br>o.style.opacity=(opc-0.1)+'';
<br>setTimeout("cleand('"+s+"','"+j+"')",100);
<br>}
<br>}
<br>}
<br>
<br>
<br>function cleand(s){
<br>if (SysIsIE){
<br>dcbIE(s,'-');
<br>}else{
<br>dcboth(s,'-');
<br>}
<br>}
<br>