Ver Mensaje Individual
  #4 (permalink)  
Antiguo 16/03/2015, 21:16
Avatar de ZoroRoronoa
ZoroRoronoa
 
Fecha de Ingreso: marzo-2011
Ubicación: California, USA
Mensajes: 824
Antigüedad: 13 años, 1 mes
Puntos: 116
Respuesta: animación - quitar, agregar clase

Me imagino que usas Js al dar click al boton y cambiar las clases.
Y para la animacion usas transition de CSS3.

Te dejo el ejemplo:
Saludos.


Ve el ejemplo aqui:
http://codepen.io/kurosaki/pen/dPQJOP


Código HTML:
Ver original
  1. <div id="midiv" class="normal"></div>
  2. <button>Animar</button>
Código CSS:
Ver original
  1. div {
  2.   background:red;
  3. }
  4.  
  5. .animando {
  6.   width:100px;
  7.   height:100px;
  8.   transition: all 2s ease-in;
  9. }
  10.  
  11. .normal {
  12.   width:0;
  13.   height:0;
  14.   transition: all 2s ease-in;
  15. }
Código Javascript:
Ver original
  1. $(document).ready( function() {
  2.  
  3.   $("button").click( function() {
  4.     var clase = $("#midiv").attr("class");
  5.     if(clase == "animando") {
  6.       //alert("existe clase animando");
  7.       //la quitamos y agregamos NORMAL
  8.       $("#midiv").attr("class","normal");
  9.         $(this).html("Animar");
  10.     } else {
  11.       //alert("CLASE NORMAL");
  12.       //agregamos ANIMACION
  13.       $("#midiv").attr("class","animando");
  14.         $(this).html("Desanimar");
  15.     }
  16.   });
  17.  
  18. });
__________________
Programador jQuery & PHP