Created
October 2, 2023 14:31
-
-
Save pj8912/cc6fd2d00b9e9e4b59551de7ecc574e6 to your computer and use it in GitHub Desktop.
Notification popup css and javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.notify { | |
position: fixed; | |
bottom: 50px; | |
right: 20px; | |
width: 400px; | |
padding: 12px; | |
background: #364c89; | |
color: #fff; | |
border-radius: 20px; | |
opacity: 0; | |
animation: fadeInOut 3s linear; | |
z-index: 400; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function notify(text, link=false){ | |
n = document.querySelector(".notify") | |
if(n !== null) n.remove() | |
if(link){ | |
el = document.createElement("a") | |
el.href = link | |
} | |
else{ | |
el = document.createElement("span") | |
} | |
el.innerText = text | |
document.body.append(el) | |
el.classList.add('notify') | |
setTimeout(function(){ | |
el.remove() | |
}, 3500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment