toast.html 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  6. <link rel="stylesheet" href="../../../dist/css/bootstrap.min.css">
  7. <title>Toast</title>
  8. <style>
  9. .notifications {
  10. position: absolute;
  11. top: 10px;
  12. right: 10px;
  13. }
  14. </style>
  15. </head>
  16. <body>
  17. <div class="container">
  18. <h1>Toast <small>Bootstrap Visual Test</small></h1>
  19. <div class="row mt-3">
  20. <div class="col-md-12">
  21. <button id="btnShowToast" class="btn btn-primary">Show toast</button>
  22. <button id="btnHideToast" class="btn btn-primary">Hide toast</button>
  23. </div>
  24. </div>
  25. </div>
  26. <div class="notifications">
  27. <div id="toastAutoHide" class="toast" role="alert" aria-live="assertive" aria-atomic="true" data-delay="2000">
  28. <div class="toast-header">
  29. <span class="d-block bg-primary rounded mr-2" style="width: 20px; height: 20px;"></span>
  30. <strong class="mr-auto">Bootstrap</strong>
  31. <small>11 mins ago</small>
  32. </div>
  33. <div class="toast-body">
  34. Hello, world! This is a toast message with <strong>autohide</strong> in 2 seconds
  35. </div>
  36. </div>
  37. <div class="toast" data-autohide="false" role="alert" aria-live="assertive" aria-atomic="true">
  38. <div class="toast-header">
  39. <span class="d-block bg-primary rounded mr-2" style="width: 20px; height: 20px;"></span>
  40. <strong class="mr-auto">Bootstrap</strong>
  41. <small class="text-muted">2 seconds ago</small>
  42. <button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
  43. <span aria-hidden="true">&times;</span>
  44. </button>
  45. </div>
  46. <div class="toast-body">
  47. Heads up, toasts will stack automatically
  48. </div>
  49. </div>
  50. </div>
  51. <script src="../../../node_modules/jquery/dist/jquery.slim.min.js"></script>
  52. <script src="../../dist/util.js"></script>
  53. <script src="../../dist/toast.js"></script>
  54. <script>
  55. $(function () {
  56. $('.toast').toast()
  57. $('#btnShowToast').on('click', function () {
  58. $('.toast').toast('show')
  59. })
  60. $('#btnHideToast').on('click', function () {
  61. $('.toast').toast('hide')
  62. })
  63. })
  64. </script>
  65. </body>
  66. </html>