jQuery Growl风格 Alert Box插件 Alert.js

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

简介

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

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

如何使用它:

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

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

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

.alert-container {
  position: fixed;
  top: 30px;
  width: 50%;
  display: flex;
  flex-direction: column;
  row-gap: 15px;
  right: 10px;
}

@media only screen and (min-width: 600px) {
  .alert-container {
    width: 400px;
  }
}

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

.modal-alert {
  box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
  display: none;
  padding: 20px 15px;
  border-radius: 8px;
  position: relative;
}

.modal-alert .content {
  display: flex;
  align-items: center;
}

.modal-alert .content svg {
  opacity: 0.9;
  margin: 0 10px;
}

.modal-alert h6 {
  opacity: 0.9;
  color: #fff;
  font-weight: 600;
  font-size: 16px;
}

.modal-alert .bar {
  height: 2px;
  left: 8px;
  bottom: 0px;
  background: rgb(255, 231, 15);
  position: absolute;
  border-radius: 4px 4px 0 0;
}

.progress {
  animation: alertProgress 5s ease;
}

@keyframes alertProgress {
  from {
      width: 90%;
  }
  to {
      width: 0;
  }
}

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

triggerAlert('This is an INFO notification');

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

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

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

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

预览截图