Código HTML:
<html> <head> <title>LIGHTBOX EXAMPLE</title> <style> .black_overlay{ display: none; position: absolute; top: 0%; left: 0%; width: 100%; height: 100%; background-color: black; z-index:1001; -moz-opacity: 0.8; opacity:.80; filter: alpha(opacity=80); } .white_content { display: none; position: absolute; top: 25%; left: 25%; width: 50%; height: 50%; padding: 16px; border: 16px solid orange; background-color: white; z-index:1002; overflow: auto; } </style> </head> <body> <p>This is the main content. To display a lightbox click <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">here</a></p> <div id="light" class="white_content">This is the lightbox content. <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">Close</a></div> <div id="fade" class="black_overlay"></div> </body> </html>
y funciona perfectamente pero no se por que a los div de mi "lightbox" no les hace efecto...
Código:
function set_opacity(div, value) { div.style.opacity = value; div.style.MozOpacity = value; div.style.KhtmlOpacity = value; div.style.filter = 'alpha(opacity=' + value*100 + ')'; div.style.zoom=1;//necesario para Explorer } var transicion=function(inicio,fin,segundos){ var _this=this; this.test=0; if(_this.intervalo)clearInterval(_this.intervalo); if(this.val && Math.abs(fin-_this.val)<0.01)return; this.val=!this.val?inicio<1?inicio+.0001:inicio:this.val; set_opacity(this, this.val); this.pasos=(fin-inicio)/100; this.pausa=segundos*10; this.intervalo=setInterval( function(){ if(_this.test>99 || Math.abs(fin-_this.val)<0.01){ clearInterval(_this.intervalo); } _this.test++; //document.getElementById("log").innerHTML=_this.test; _this.val=_this.val+_this.pasos; if(_this.val<=.01) _this.style.display='none'; else _this.style.display='block'; set_opacity(_this, _this.val); },this.pausa); } function ver(){ var obj=document.getElementById("light"); transicion.call(obj,0,1,3); } function cerrar(){ var obj=document.getElementById("light"); transicion.call(obj,1,0,3); }
muchisimas Gracias