Advertisement
RyanJEarnshaw

Untitled

Oct 13th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. /* The snackbar - position it at the bottom and in the middle of the screen */
  2. #snackbar {
  3. visibility: hidden; /* Hidden by default. Visible on click */
  4. min-width: 250px; /* Set a default minimum width */
  5. margin-left: -125px; /* Divide value of min-width by 2 */
  6. background-color: #333; /* Black background color */
  7. color: #fff; /* White text color */
  8. text-align: center; /* Centered text */
  9. border-radius: 2px; /* Rounded borders */
  10. padding: 16px; /* Padding */
  11. position: fixed; /* Sit on top of the screen */
  12. z-index: 1; /* Add a z-index if needed */
  13. left: 50%; /* Center the snackbar */
  14. bottom: 30px; /* 30px from the bottom */
  15. }
  16.  
  17. /* Show the snackbar when clicking on a button (class added with JavaScript) */
  18. #snackbar.show {
  19. visibility: visible; /* Show the snackbar */
  20.  
  21. /* Add animation: Take 0.5 seconds to fade in and out the snackbar.
  22. However, delay the fade out process for 2.5 seconds */
  23. -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
  24. animation: fadein 0.5s, fadeout 0.5s 2.5s;
  25. }
  26.  
  27. /* Animations to fade the snackbar in and out */
  28. @-webkit-keyframes fadein {
  29. from {bottom: 0; opacity: 0;}
  30. to {bottom: 30px; opacity: 1;}
  31. }
  32.  
  33. @keyframes fadein {
  34. from {bottom: 0; opacity: 0;}
  35. to {bottom: 30px; opacity: 1;}
  36. }
  37.  
  38. @-webkit-keyframes fadeout {
  39. from {bottom: 30px; opacity: 1;}
  40. to {bottom: 0; opacity: 0;}
  41. }
  42.  
  43. @keyframes fadeout {
  44. from {bottom: 30px; opacity: 1;}
  45. to {bottom: 0; opacity: 0;}
  46. }
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57. function myFunction() {
  58. // Get the snackbar DIV
  59. var x = document.getElementById("snackbar")
  60.  
  61. // Add the "show" class to DIV
  62. x.className = "show";
  63.  
  64. // After 3 seconds, remove the show class from DIV
  65. setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement