Narendra123

success message popup

Sep 17th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta name="viewport" content="width=device-width, initial-scale=1">
  5. <style>
  6. #snackbar {
  7. visibility: hidden;
  8. min-width: 250px;
  9. background-color: #333;
  10. color: #fff;
  11. text-align: center;
  12. border-radius: 2px;
  13. padding: 16px;
  14. position: fixed;
  15. z-index: 1;
  16. left: 50%;
  17. bottom: 30px;
  18. font-size: 17px;
  19. }
  20.  
  21. #snackbar.show {
  22. visibility: visible;
  23. -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
  24. animation: fadein 0.5s, fadeout 0.5s 2.5s;
  25. }
  26.  
  27. @-webkit-keyframes fadein {
  28. from {bottom: 0; opacity: 0;}
  29. to {bottom: 30px; opacity: 1;}
  30. }
  31.  
  32. @keyframes fadein {
  33. from {bottom: 0; opacity: 0;}
  34. to {bottom: 30px; opacity: 1;}
  35. }
  36.  
  37. @-webkit-keyframes fadeout {
  38. from {bottom: 30px; opacity: 1;}
  39. to {bottom: 0; opacity: 0;}
  40. }
  41.  
  42. @keyframes fadeout {
  43. from {bottom: 30px; opacity: 1;}
  44. to {bottom: 0; opacity: 0;}
  45. }
  46. </style>
  47. </head>
  48. <body>
  49.  
  50.  
  51. <button onclick="myFunction()">Show Snackbar</button>
  52.  
  53. <div id="snackbar">Some text some message..</div>
  54.  
  55. <script>
  56. function myFunction() {
  57. var x = document.getElementById("snackbar");
  58. x.className = "show";
  59. setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
  60. }
  61. </script>
  62.  
  63. </body>
  64. </html>
Add Comment
Please, Sign In to add comment