snackbar.css 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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: 50%; /* 30px from the bottom */
  15. }
  16. /* Show the snackbar when clicking on a button (class added with JavaScript) */
  17. .snackbar.show {
  18. visibility: visible; /* Show the snackbar */
  19. /* Add animation: Take 0.5 seconds to fade in and out the snackbar.
  20. However, delay the fade out process for 2.5 seconds */
  21. -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
  22. animation: fadein 0.5s, fadeout 0.5s 2.5s;
  23. }
  24. /* Animations to fade the snackbar in and out */
  25. @-webkit-keyframes fadein {
  26. from {bottom: 45%; opacity: 0;}
  27. to {bottom: 50%; opacity: 1;}
  28. }
  29. @keyframes fadein {
  30. from {bottom: 45%; opacity: 0;}
  31. to {bottom: 50%; opacity: 1;}
  32. }
  33. @-webkit-keyframes fadeout {
  34. from {bottom: 50%; opacity: 1;}
  35. to {bottom: 45%; opacity: 0;}
  36. }
  37. @keyframes fadeout {
  38. from {bottom: 50%; opacity: 1;}
  39. to {bottom: 45%; opacity: 0;}
  40. }