You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.7 KiB

8 months ago
  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. margin-left: -125px;
  10. background-color: #333;
  11. color: #fff;
  12. text-align: center;
  13. border-radius: 2px;
  14. padding: 16px;
  15. position: fixed;
  16. z-index: 1;
  17. left: 50%;
  18. top: 30px;
  19. font-size: 17px;
  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. @-webkit-keyframes fadein {
  27. from {top: 0; opacity: 0;}
  28. to {top: 30px; opacity: 1;}
  29. }
  30. @keyframes fadein {
  31. from {top: 0; opacity: 0;}
  32. to {top: 30px; opacity: 1;}
  33. }
  34. @-webkit-keyframes fadeout {
  35. from {top: 30px; opacity: 1;}
  36. to {top: 0; opacity: 0;}
  37. }
  38. @keyframes fadeout {
  39. from {top: 30px; opacity: 1;}
  40. to {top: 0; opacity: 0;}
  41. }
  42. </style>
  43. </head>
  44. <body>
  45. <h2>Snackbar / Toast</h2>
  46. <p>Snackbars are often used as a tooltips/popups to show a message at the bottom of the screen.</p>
  47. <p>Click on the button to show the snackbar. It will disappear after 3 seconds.</p>
  48. <button onclick="myFunction()">Show Snackbar</button>
  49. <div id="snackbar">Some text some message..</div>
  50. <script>
  51. function myFunction() {
  52. var x = document.getElementById("snackbar");
  53. x.className = "show";
  54. setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
  55. }
  56. </script>
  57. </body>
  58. </html>