Ver Mensaje Individual
  #6 (permalink)  
Antiguo 05/01/2015, 07:30
mauritosuarez
 
Fecha de Ingreso: octubre-2014
Ubicación: Buenos Aires
Mensajes: 278
Antigüedad: 9 años, 8 meses
Puntos: 12
Respuesta: Cuadro desde base de datos

ahh ok diego, te dejo un código jquery que cada vez que se refresque la web aparecerá un fondo (imagen) distinto.

Código Javascript:
Ver original
  1. $(docuement).ready(function() {
  2.  
  3.     // Defines todas las imagenes posibles, las imagenes son cargadas desde el css
  4.    
  5.     var bglist = new Array(13);
  6.         bglist[0] = "fondo1";
  7.         bglist[1] = "fondo2";
  8.         bglist[2] = "fondo3";
  9.         bglist[3] = "fondo4";
  10.         bglist[4] = "fondo5";
  11.         bglist[5] = "fondo6";
  12.         bglist[6] = "fondo7";
  13.         bglist[7] = "fondo8";
  14.         bglist[8] = "fondo9";
  15.         bglist[9] = "fondo10";
  16.         bglist[10] = "fondo11";
  17.         bglist[11] = "fondo12";
  18.         bglist[12] = "fondo13";
  19.    
  20.         // Realizas un random, cada vez que se actualice aparecera un fondo distinto de los 13 existentes en este ejemplo  
  21.         var rand = Math.floor(Math.random() * 13);
  22.        
  23.         // #right es el div donde se mostran las imagenes aleatoremente cada vez que se refresque.
  24.         $("#right").addClass(bglist[rand]);
  25.  
  26.    });


Código CSS:
Ver original
  1. .fondo1
  2. {
  3.     width:700px;
  4.     height:800px;
  5.     display:table-cell;
  6.     margin-top:8px;
  7.     margin-right:8px;
  8.     float:right;
  9.     background-image:url('/Content/fondos/fondo1-1.jpg');
  10.     background-repeat:no-repeat;
  11. }
  12.  
  13. .fondo2
  14. {
  15.     width:700px;
  16.     height:800px;
  17.     display:table-cell;
  18.     margin-top:8px;
  19.     margin-right:8px;
  20.     float:right;
  21.     background-image:url('/Content/fondos/fondo1-2.jpg');
  22.     background-repeat:no-repeat;
  23. }
  24.  
  25. /*** y así hasta llegar hasta el fondo 13 o los que gustes. ***/

Espero te sirva, saludos.

Recuerda que debes añadir la librería de jquery para que esto funcione.
__________________
http://www.sp-vision.net