Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/12/2013, 18:23
isabelramirezmontoya
 
Fecha de Ingreso: noviembre-2010
Mensajes: 204
Antigüedad: 13 años, 5 meses
Puntos: 1
Como centrar imagenes con diferentes dimensiones en un DIV

Chicos buenas tardes, me pueden colaborar con esta duda.

Con el codigo que coloco abajo, logro intercambiar 5 imagenes en un DIV (funciona perfecto), pero tengo un problema, como logro centrar (vertical / horizontal) las imagenes en el DIV cuando cada imagen tiene dimensiones diferentes.

Codigo PHP
Código HTML:
Ver original
  1. <?php
  2.  
  3. $imagen1 = $codigo_imagenes1;
  4. $imagen2 = $codigo_imagenes2;
  5. $imagen3 = $codigo_imagenes3;
  6. $imagen4 = $codigo_imagenes4;
  7. $imagen5 = $codigo_imagenes5;
  8.  
  9.  
  10. echo '<div>';
  11. echo '<img id="imagen_central" src="http://controles.com/fotos/'.$imagen1.'">';
  12. echo '</div>';
  13.  
  14. echo '<center>';
  15.  
  16.  
  17. echo '<img src="http://controles.com/fotos/'.$imagen1.'" width="15" height="15" onclick="ver_imagen(this.src)">';
  18. echo ' ';
  19. echo '<img src="http://controles.com/fotos/'.$imagen2.'" width="15" height="15" onclick="ver_imagen(this.src)">';
  20. echo ' ';
  21. echo '<img src="http://controles.com/fotos/'.$imagen3.'" width="15" height="15" onclick="ver_imagen(this.src)">';
  22. echo ' ';
  23. echo '<img src="http://controles.com/fotos/'.$imagen4.'" width="15" height="15" onclick="ver_imagen(this.src)">';
  24. echo ' ';
  25. echo '<img src="http://controles.com/fotos/'.$imagen5.'" width="15" height="15" onclick="ver_imagen(this.src)">';
  26.  
  27. echo '</center>';
  28.  
  29. ?>

Codigo JAVASCRIPT
Código HTML:
Ver original
  1. function ver_imagen(src)
  2. {
  3. document.getElementById("imagen_central").src = src;
  4. }

Gracias