Ver Mensaje Individual
  #3 (permalink)  
Antiguo 08/12/2013, 11:44
Avatar de pzin
pzin
Moderata 😈
 
Fecha de Ingreso: julio-2002
Ubicación: Islas Canarias
Mensajes: 10.488
Antigüedad: 21 años, 8 meses
Puntos: 2114
Respuesta: Alternar backgrounds

No te hace falta PHP, te basta con hacerlo con CSS usando nth-child():

Código CSS:
Ver original
  1. .fondo_caja:nth-child(3n+1) {
  2.   background: firebrick;
  3. }
  4.  
  5. .fondo_caja:nth-child(3n+2) {
  6.   background: green;
  7. }
  8.  
  9. .fondo_caja:nth-child(3n+3) {
  10.   background: purple;
  11. }

También puedes usar nth-of-type() si el contenedor padre contiene otros elementos que no sean div.fondo_caja.