Skip to content

Instantly share code, notes, and snippets.

@pj8912
Created October 2, 2023 14:31
Show Gist options
  • Save pj8912/cc6fd2d00b9e9e4b59551de7ecc574e6 to your computer and use it in GitHub Desktop.
Save pj8912/cc6fd2d00b9e9e4b59551de7ecc574e6 to your computer and use it in GitHub Desktop.
Notification popup css and javascript
.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;
}
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