Ver Mensaje Individual
  #18 (permalink)  
Antiguo 25/02/2013, 09:17
Davi91
 
Fecha de Ingreso: noviembre-2011
Ubicación: Sevilla
Mensajes: 48
Antigüedad: 12 años, 5 meses
Puntos: 1
Respuesta: Retraso efecto :hover al aplicar animation

Gracias por los comentarios!

Básicamente se trata de de una serie de imágenes que van desapareciendo al tamaño de la pantalla y con un z-index bajo, pongo el código;

Primero creas el "wrap" que contendrá las imágenes.

Código HTML:
<div class="fija">
    <div class="movimiento" id="imagen1"></div>
    <div class="movimiento" id="imagen2"></div>
    <div class="movimiento" id="imagen3"></div>
    <div class="movimiento" id="imagen4"></div>
</div> 
Y se le aplica el tamaño y la posición

Código CSS:
Ver original
  1. .fija {
  2.     position: fixed;
  3.     width: 100%;
  4.     height: 100%;
  5.     top: 0px;
  6.     left: 0px;
  7.     z-index: 0;
  8. }
  9. .movimiento {
  10.     min-width: 100%;
  11.     min-height: 100%;
  12.     position: absolute;
  13.     top: 0px;
  14.     left: 0px;
  15.     opacity:0;
  16.     z-index: 90;
  17. /* Este z-index puede ser un error en el resto de mi código, quizás sea opcional para vosotros */
  18.     background-size:cover;
  19. /* Se le aplica la animación que determinará el movimiento y la opacidad de las imágenes */
  20.     -webkit-animation: imageAnimation 24s linear infinite 0s;
  21.     -moz-animation: imageAnimation 24s linear infinite 0s;
  22.     -o-animation: imageAnimation 24s linear infinite 0s;
  23.     -ms-animation: imageAnimation 24s linear infinite 0s;
  24.     animation: imageAnimation 24s linear infinite 0s;  
  25. /* La duración de la animación dependerá de la cantidad de imágenes que uséis, yo he usado 4 a 6 segundos cada una */
  26. }

Se aplican los id para las imágenes y el delay para la animación (así no se aplica la animación a todas a la vez, sino que va afectando una a una y en orrden

Código CSS:
Ver original
  1. #imagen1 {
  2.     background-image:url(http://blog.razorsanddiapers.com/wp-content/uploads/2012/10/concert.jpg);
  3. }
  4. #imagen2 {
  5.     background-image:url(http://www.downloadfreebackgrounds.net/backgrounds/night-party-club-background.jpg);
  6.     -webkit-animation-delay: 6s;
  7.     -moz-animation-delay: 6s;
  8.     -o-animation-delay: 6s;
  9.     -ms-animation-delay: 6s;
  10.     animation-delay: 6s;
  11. }
  12. #imagen3 {
  13.     background-image:url(http://www.newcaspics.info/wp-content/uploads/wallpaper-for-macbook-air-13_2727_1.jpg);
  14.     -webkit-animation-delay: 12s;
  15.     -moz-animation-delay: 12s;
  16.     -o-animation-delay: 12s;
  17.     -ms-animation-delay: 12s;
  18.     animation-delay: 12s;
  19. }
  20. #imagen4 {
  21.     background-image:url(http://www.downloadfreebackgrounds.net/backgrounds/night-party-club-background.jpg);
  22.     -webkit-animation-delay: 18s;
  23.     -moz-animation-delay: 18s;
  24.     -o-animation-delay: 18s;
  25.     -ms-animation-delay: 18s;
  26.     animation-delay: 18s;
  27. }

Y la animación con todos sus prefijos

Código CSS:
Ver original
  1. @-webkit-keyframes imageAnimation {
  2.     0% {
  3.         opacity: 0;
  4.         -webkit-animation-timing-function: ease-in;
  5.     }
  6.     8% {
  7.         opacity: 1;
  8.         -webkit-transform: scale(1.05) rotate(1deg);
  9.         -webkit-animation-timing-function: ease-out;
  10.     }
  11.     17% {
  12.         opacity: 1;
  13.         -webkit-transform: scale(1.1) rotate(2deg);
  14.     }
  15.     25% {
  16.         opacity: 0;
  17.         -webkit-transform: scale(1.1) rotate(3deg);
  18.     }
  19.     100% { opacity: 0; }
  20. }
  21.  
  22. @-moz-keyframes imageAnimation {
  23.     0% {
  24.         opacity: 0;
  25.         -moz-animation-timing-function: ease-in;
  26.     }
  27.     8% {
  28.         opacity: 1;
  29.         -moz-transform: scale(1.05) rotate(3deg);
  30.         -moz-animation-timing-function: ease-out;
  31.     }
  32.     17% {
  33.         opacity: 1;
  34.         -moz-transform: scale(1.1) rotate(3deg);
  35.     }
  36.     25% {
  37.         opacity: 0;
  38.         -moz-transform: scale(1.1) rotate(3deg);
  39.     }
  40.     100% { opacity: 0 }
  41. }
  42. @-o-keyframes imageAnimation {
  43.     0% {
  44.         opacity: 0;
  45.         -o-animation-timing-function: ease-in;
  46.     }
  47.     8% {
  48.         opacity: 1;
  49.         -o-transform: scale(1.05) rotate(3deg);
  50.         -o-animation-timing-function: ease-out;
  51.     }
  52.     17% {
  53.         opacity: 1;
  54.         -o-transform: scale(1.1) rotate(3deg);
  55.     }
  56.     25% {
  57.         opacity: 0;
  58.         -o-transform: scale(1.1) rotate(3deg);
  59.     }
  60.     100% { opacity: 0 }
  61. }
  62. @-ms-keyframes imageAnimation {
  63.     0% {
  64.         opacity: 0;
  65.         -ms-animation-timing-function: ease-in;
  66.     }
  67.     8% {
  68.         opacity: 1;
  69.         -ms-transform: scale(1.05) rotate(3deg);
  70.         -ms-animation-timing-function: ease-out;
  71.     }
  72.     17% {
  73.         opacity: 1;
  74.         -ms-transform: scale(1.1) rotate(3deg);
  75.     }
  76.     25% {
  77.         opacity: 0;
  78.         -ms-transform: scale(1.1) rotate(3deg);
  79.     }
  80.     100% { opacity: 0 }
  81. }
  82. @keyframes imageAnimation {
  83.     0% {
  84.         opacity: 0;
  85.         animation-timing-function: ease-in;
  86.     }
  87.     8% {
  88.         opacity: 1;
  89.         transform: scale(1.05) rotate(3deg);
  90.         animation-timing-function: ease-out;
  91.     }
  92.     17% {
  93.         opacity: 1;
  94.         transform: scale(1.1) rotate(3deg);
  95.     }
  96.     25% {
  97.         opacity: 0;
  98.         transform: scale(1.1) rotate(3deg);
  99.     }
  100.     100% { opacity: 0 }
  101. }

Espero que os haya servido, , avisar si tenéis dudas y para los que entiendan de esto, seguro que hay algún fallo o alguna línea que sobra, pero a mi me funciona así xD