Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/08/2012, 09:14
Avatar de patilanz
patilanz
 
Fecha de Ingreso: enero-2012
Mensajes: 880
Antigüedad: 12 años, 4 meses
Puntos: 29
Pregunta Mostrar una capa despues de que pase algo

Hola quiero hacer que cuando una imagen ya ha llegado a los 456 px de anchura se muestre un cuadro de aviso y luego cuando empieza a poner se mas pequena es decir que tener menos anchura se oculto. Y luego si la imagen llega otra vez tambien se muestre y luego oculte.
Tengo el siguiente codigo javascript

Código Javascript:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Documento sin título</title>
  6. <style type="text/css">
  7. #imagen {
  8.     width:20px;
  9.     height:20px;
  10.     border:thin;
  11.     border-width:1px;
  12.     border-radius:1px;
  13.     -webkit-transition:all 2s ease;
  14.     -moz-transition:all 1s ease;
  15.     -o-transition:all 1s ease;
  16.     transition:all 1s ease;
  17. }
  18. </style>
  19. <script language="javascript">
  20. function agrandar(){
  21. document.getElementById('imagen').style.width='456px';
  22. document.getElementById('imagen').style.height='473px';
  23. document.getElementById('imagen').style.borderRadius='20px';
  24. setTimeout(mostrar(),2000);
  25. }
  26. function volver() {
  27. document.getElementById('imagen').style.width='20px';
  28. document.getElementById('imagen').style.height='20px';
  29. document.getElementById('imagen').style.borderRadius='1px'
  30. }
  31. function mostrar() {
  32. var imagen = document.images[0].width;
  33. if(imagen == 456){
  34. document.getElementById('mostrar').style.visibility = 'visible';
  35. } else {
  36. document.getElementById('mostrar').style.visibility = 'hidden';
  37. }
  38.  
  39. }
  40.  
  41. </script>
  42. </head>
  43.  
  44. <body onload="mostrar()">
  45. <img src="images2/combate_gatuno.jpg" id="imagen" onmouseover="agrandar()" onclick="volver();" />
  46. <span style="position:absolute; left: 462px; top: 146px; width: 210px; height: 41px; background-color:#0CF; padding:10px; border-radius:10px; visibility:hidden;" id="mostrar">Pulse en la imagen para volver a su estado anterior.</span>
  47. </body>
  48. </html>

Pero el problema es que la capa se muestra solo si ha llegado a los 456 px y el raton esta sobre la imagen pero yo quiero que no aga falta que este sobre la imagen y luego tambien desaparece si solo no tiene los 456 px y el raton esta sobre la imagen...
Tengo la pagina subida aqui por si quieren verla : http://javascriptcsspr.comli.com/css/imagen_agrandar.html

Gracias :)