Guest User

Untitled

a guest
Feb 16th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. @keyframes myAnimation{
  2. 0%{
  3. opacity: 1;
  4. transform: rotateX(90deg);
  5. }
  6. 50%{
  7. opacity: 0.5;
  8. transform: rotateX(0deg);
  9. }
  10. 100%{
  11. display: none;
  12. opacity: 0;
  13. transform: rotateX(90deg);
  14. }
  15. }
  16.  
  17. #myelement{
  18. animation-name: myAnimation;
  19. animation-duration: 2000ms;
  20. animation-fill-mode: forwards;
  21. }
  22.  
  23. <style>
  24. #test{
  25. background: red;
  26. height: 100px;
  27. width: 400px;
  28. transition: height 1s;
  29. }
  30.  
  31. #test.hide {
  32. height: 0;
  33. }
  34.  
  35. </style>
  36.  
  37. <div id="test"> </div>
  38.  
  39. <button>Hide the Div</button>
  40.  
  41. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.js"></script>
  42. <script>
  43.  
  44.  
  45. $('button').click(function(){
  46. removeWithAnimate('#test');
  47. });
  48.  
  49.  
  50. function removeWithAnimate(id){
  51. $(id).addClass('hide');
  52. setTimeout( function(){
  53. $(id).remove()
  54. },1000);;
  55. }
  56.  
  57. </script>
Add Comment
Please, Sign In to add comment