jQuery Growl风格 Alert Box插件 Alert.js

  • 源码大小:6.21KB
  • 所需积分:1积分
  • 源码编号:19JP-3670
  • 浏览次数:659次
  • 最后更新:2023年07月09日
  • 所属栏目:其他
本站默认解压密码:19jp.com 或 19jp_com

简介

Alert.js是一个小型jQuery插件,用于创建受OS X启发的咆哮通知,5秒后自动关闭。

这些通知可以用于显示任何类型的警报、警告和通知,并确保您不必用丑陋的警报框覆盖设计精美的页面。

如何使用它:

1.在jQuery库之后加载主脚本alert.js。

  1. <script src="/path/to/cdn/jquery.min.js"></script>
  2. <script src="/path/to/alert.js"></script>

2.设置警报容器的样式。

  1. .alert-container {
  2. position: fixed;
  3. top: 30px;
  4. width: 50%;
  5. display: flex;
  6. flex-direction: column;
  7. row-gap: 15px;
  8. right: 10px;
  9. }
  10.  
  11. @media only screen and (min-width: 600px) {
  12. .alert-container {
  13. width: 400px;
  14. }
  15. }

3.警报框所需的CSS样式。

  1. .modal-alert {
  2. box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
  3. display: none;
  4. padding: 20px 15px;
  5. border-radius: 8px;
  6. position: relative;
  7. }
  8.  
  9. .modal-alert .content {
  10. display: flex;
  11. align-items: center;
  12. }
  13.  
  14. .modal-alert .content svg {
  15. opacity: 0.9;
  16. margin: 0 10px;
  17. }
  18.  
  19. .modal-alert h6 {
  20. opacity: 0.9;
  21. color: #fff;
  22. font-weight: 600;
  23. font-size: 16px;
  24. }
  25.  
  26. .modal-alert .bar {
  27. height: 2px;
  28. left: 8px;
  29. bottom: 0px;
  30. background: rgb(255, 231, 15);
  31. position: absolute;
  32. border-radius: 4px 4px 0 0;
  33. }
  34.  
  35. .progress {
  36. animation: alertProgress 5s ease;
  37. }
  38.  
  39. @keyframes alertProgress {
  40. from {
  41. width: 90%;
  42. }
  43. to {
  44. width: 0;
  45. }
  46. }

4.显示INFORMATION(信息)警告框。

  1. triggerAlert('This is an INFO notification');

5.显示ERROR(错误)警告框。

  1. triggerAlert('This is an ERROR notification', 'error');

6.显示SUCCESS(成功)警告框。

  1. triggerAlert('This is a SUCCESS notification', 'success');

预览截图