Minimal Stackable Toast-style Notification Bars In jQuery

File Size: 5.68 KB
Views Total: 287
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
Minimal Stackable Toast-style Notification Bars In jQuery

A minimal jQuery implementation of the toast-like notification bars that are easy to style using CSS and automatically disappear after a period of time.

See Also:

How to use it:

1. Load the main script after jQuery.

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

2. Create toast notifications and determine the timeout in milliseconds.

toast('Toast Notification 1', 3000);
toast('Toast Notification 2', 4000);
toast('Toast Notification 3', 5000);
...

3. Apply CSS styles to the toast notification bars.

.toast {
  position: relative;
  width: 100%;
  border-top: 1px solid #000;
  background-color: #222;
  color: #fff;
  font-size: 20px;
}

.toast__frame {
  position: fixed;
  bottom: 0;
  right: 0;
  left: 0;
  z-index: 100;
}

.toast__text {
  text-align: center;
  padding: 15px;
}

.toast__close {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.close-button {
  display: inline-block;
  width: 20px;
  height: 20px;
  position: relative;
  background-color: #444;
  cursor: pointer;
  border-radius: 50%;
}

.close-button::before,
.close-button::after {
  display: block;
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 70%;
  height: 10%;
  margin: -6% 0 0 -33%;
  background: #fff;
}

.close-button::before {
  transform: rotate(-45deg);
}

.close-button::after {
  transform: rotate(45deg);
}

This awesome jQuery plugin is developed by it-web-life. For more Advanced Usages, please check the demo page or visit the official website.