Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="px-app px-continer">
  <div class="px-gridbox">
    <div class="px-griditem item-success" onclick="ntf('This is a Success Notification')">
      <svg xmlns="http://www.w3.org/2000/svg" class="notification-icon" viewBox="0 0 512 512"><title>Checkmark</title><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M416 128L192 384l-96-96"/></svg><span>Success</span>
    </div>
    <div class="px-griditem item-warning" onclick="ntf('This is a Warning Notification','warning')">
      <svg xmlns="http://www.w3.org/2000/svg" class="notification-icon" viewBox="0 0 512 512"><title>Warning</title><path d="M85.57 446.25h340.86a32 32 0 0028.17-47.17L284.18 82.58c-12.09-22.44-44.27-22.44-56.36 0L57.4 399.08a32 32 0 0028.17 47.17z" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/><path d="M250.26 195.39l5.74 122 5.73-121.95a5.74 5.74 0 00-5.79-6h0a5.74 5.74 0 00-5.68 5.95z" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/><path style="fill:#f7d78b" d="M256 397.25a20 20 0 1120-20 20 20 0 01-20 20z"/></svg><span> Warning</span>
    </div>
       <div class="px-griditem item-error" onclick="ntf('This is an Error Notification','error')">
      <svg xmlns="http://www.w3.org/2000/svg" class="notification-icon" viewBox="0 0 512 512"><title>Close Circle</title><path d="M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z" fill="none" stroke="currentColor" stroke-miterlimit="10" stroke-width="32"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M320 320L192 192M192 320l128-128"/></svg>
      <span>Eroor</span>
    </div>
    </div>
</div>



              
            
!

CSS

              
                :root {
  --px-color-bodybg: rgb(19, 26, 41);
  --px-color-boxbg: rgb(12, 16, 29);
  --px-color-boxborder: rgb(27, 34, 55);
  --px-border-radius: 6px;
}

html {
  font-size: 16px;
  font-family:arial;
}
body {
  font-size: 1rem;
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  background-color: var(--px-color-bodybg);
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
}

.px-app,
.px-app *,
.px-app *::before,
.px-app *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  outline: 0;
}
.px-continer {
  width: 100%;
  max-width: 600px;
  padding: 4rem 0;
}
.px-gridbox {
  padding-bottom: 3rem;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(3, 1fr);
}
.px-griditem {
  font-size: 1rem;
  min-height: 6rem;
  border: 2px solid var(--px-color-boxborder);
  border-radius: var(--px-border-radius);
  background-color: var(--px-color-boxbg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor:pointer;
}

.px-griditem svg {
  width: 90px;
  padding: 10px;
  color: #b3b3b3;
}
.px-griditem span {
  display: block;
  width: 100%;
  background: #fff;
  text-align: center;
  border-radius: 0 0 4px 4px;
  padding: 5px;
}


.px-griditem.item-success {
  border-color: #a9eea7;
}
.px-griditem.item-success span {
  background: #a9eea7;
}
.px-griditem.item-success svg {
  color: #a9eea7;
}
.px-griditem.item-warning {
  border-color: #f7d78b;
}
.px-griditem.item-warning span {
  background: #f7d78b;
}
.px-griditem.item-warning svg {
  color: #f7d78b;
}
.px-griditem.item-error {
  border-color: #fb6565;
}
.px-griditem.item-error span {
  background: #fb6565;
}
.px-griditem.item-error svg {
  color: #fb6565;
}

/*End Demo*/
.notifications {
    position: absolute;
    left: 0;
    bottom: 0;
    z-index: 9999;
    padding: 15px;
}

.notification {
	display: flex;
	padding: 5px 10px;
	justify-content: space-between;
	background: rgba(255, 255, 255, 0.5);
	border: 1px solid;
	border-radius: 3px;
	margin: 5px 0;
	-webkit-animation: anm_slide_right 0.2s ease-in-out normal;
	animation: anm_slide_right 0.2s ease-in-out normal;
	align-items: center;
	padding-right: 32px;
	position: relative;
	-webkit-backdrop-filter: blur(2px);
	backdrop-filter: blur(2px);
}

.notification-icon {
    padding-right: 10px;
    box-sizing: border-box;
    width: 35px;
}

.message {
    display: block;
    flex-basis: 100%;
    flex-grow: 1;
}

.notification .close {
    padding: 0 7px;
    margin-left: 25px;
    cursor: pointer;
    position: absolute;
    right: 5px;
    top: 43%;
    line-height: 0;
    transform: translate(0, 0);
}

.notification.success {
	color: #006005;
	background: rgba(255, 255, 255, 0.78);
	border-color: rgba(0,255,0,.4);
}

.notification.alert {
    border-color: #b7b700;
    color: #000;
    background: #f0efa6;
}

.notification.warning {
    color: yellow;
}

.notification.error {
	color: red;
	border-color: rgba(236, 96, 96, 0.4);
}



@keyframes anm_slide_right {
    from {
        transform: translate(-110%, 0);
        opacity: 0;
    }

    to {
        transform: translate(0, 0);
        opacity: 1;
    }
}

              
            
!

JS

              
                class Notification {
    constructor({ ...options }) {
        this.type = options.type || "success";
        this.message = options.message || "";
        this.timeout = options.timeout || 6000;
        //if not success then error and timeout should increse
        if (this.type !== "success") {
            this.timeout = this.timeout * 2;
        }
        this.bind();
    }
    build() {
        //element
        let singleElement = document.createElement("div");
        singleElement.classList.add("notification");
        singleElement.classList.add(this.type);
        if (this.type == 'alert' || this.type == 'warning') {
            singleElement.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" class="notification-icon" viewBox="0 0 512 512"><title>Warning</title><path d="M85.57 446.25h340.86a32 32 0 0028.17-47.17L284.18 82.58c-12.09-22.44-44.27-22.44-56.36 0L57.4 399.08a32 32 0 0028.17 47.17z" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/><path d="M250.26 195.39l5.74 122 5.73-121.95a5.74 5.74 0 00-5.79-6h0a5.74 5.74 0 00-5.68 5.95z" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/><path d="M256 397.25a20 20 0 1120-20 20 20 0 01-20 20z"/></svg>';
        } else if (this.type == 'success') {
            singleElement.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" class="notification-icon" viewBox="0 0 512 512"><title>Checkmark</title><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M416 128L192 384l-96-96"/></svg>';
        } else {
            singleElement.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" class="notification-icon" viewBox="0 0 512 512"><title>Close Circle</title><path d="M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z" fill="none" stroke="currentColor" stroke-miterlimit="10" stroke-width="32"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M320 320L192 192M192 320l128-128"/></svg>';
        }
        //message
        let messageElement = document.createElement("div");
        messageElement.classList.add("message");
        messageElement.innerHTML = this.message;
        singleElement.appendChild(messageElement);
        //close
        let closeElement = document.createElement("div");
        closeElement.classList.add("close");
        closeElement.innerHTML = "&times;";
        closeElement.addEventListener("click", () => {
            singleElement.remove();
        });
        singleElement.appendChild(closeElement);
        singleElement.classList.add('slide-righr');
        return singleElement;
    }

    bind() {
        //check existance of notifications wraper
        let notificationsWrapper = document.querySelector(".notifications");
        if (!notificationsWrapper) {
            notificationsWrapper = document.createElement("div");
            notificationsWrapper.classList.add("notifications");
            document.body.appendChild(notificationsWrapper);
        }
        //append notification
        notificationsWrapper.appendChild(this.build());
        //remove notification after timeout
        setTimeout(() => {
            if (notificationsWrapper.firstChild) {
                notificationsWrapper.removeChild(notificationsWrapper.firstChild);
            }
        }, this.timeout);
    }
}

window.ntf = function (txt, cls) {
    new Notification({
        message: txt,
        type: cls
    });
};
              
            
!
999px

Console