Created
December 18, 2016 12:24
-
-
Save anonymous/78e0a21a50fb0a7be9b0c0333ce9d3e1 to your computer and use it in GitHub Desktop.
// source http://jsbin.com/fominix
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
body{ | |
width: 960px; | |
margin: 0 auto; | |
padding: 0; | |
} | |
* { | |
box-sizing: border-box; | |
} | |
.btn { | |
padding: 15px 30px; | |
color: #FFF; | |
text-align: center; | |
background: #4CAF50; | |
border: 0; | |
cursor: pointer; | |
font-family: Verdana,sans-serif; | |
font-size: 15px; | |
margin: 10px; | |
text-decoration: none; | |
display: inline-block; | |
} | |
.show { | |
visibility: visible !important; | |
-webkit-animation: fadeIn 0.5s, fadeOut 0.5s 2.5s; | |
animation: fadeIn 0.5s, fadeOut 0.5s 2.5s; | |
} | |
@keyframes fadeIn { | |
from {bottom: 0; opacity: 0;} | |
to {bottom: 30px; opacity: 1;} | |
} | |
@keyframes fadeOut { | |
from {bottom: 30px; opacity: 1;} | |
to {bottom: 0; opacity: 0;} | |
} | |
@-webkit-keyframes fadeIn { | |
from {bottom: 0; opacity: 0;} | |
to {bottom: 30px; opacity: 1;} | |
} | |
@-webkit-keyframes fadeOut { | |
from {bottom: 30px; opacity: 1;} | |
to {bottom: 0; opacity: 0;} | |
} | |
#toaster { | |
position: fixed; | |
visibility: hidden; | |
padding: 20px; | |
background: #333; | |
color: #FFF; | |
text-align: center; | |
border: 1px solid #333; | |
min-width: 250px; | |
margin-left: -125px; | |
left: 50%; | |
bottom: 30px; | |
border-radius: 2px; | |
z-index: 1; | |
} | |
</style> | |
<script> | |
// function triggers on click of button | |
function trigger(){ | |
var toastNotify = document.getElementById('toaster'); | |
// add classname to show the toast notify div | |
toastNotify.className = "show"; | |
// hide it automatically after 3s | |
setTimeout(function(){ | |
toastNotify.className = toastNotify.className.replace("show",""); | |
}, 3000); | |
} | |
</script> | |
</head> | |
<body> | |
<button class="btn" id="toastNotifyTrigger" onclick="trigger()">Trigger toast</button> | |
<div id="toaster" class="toast">You have 1 new friend request</div> | |
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
body{ | |
width: 960px; | |
margin: 0 auto; | |
padding: 0; | |
} | |
* { | |
box-sizing: border-box; | |
} | |
.btn { | |
padding: 15px 30px; | |
color: #FFF; | |
text-align: center; | |
background: #4CAF50; | |
border: 0; | |
cursor: pointer; | |
font-family: Verdana,sans-serif; | |
font-size: 15px; | |
margin: 10px; | |
text-decoration: none; | |
display: inline-block; | |
} | |
.show { | |
visibility: visible !important; | |
-webkit-animation: fadeIn 0.5s, fadeOut 0.5s 2.5s; | |
animation: fadeIn 0.5s, fadeOut 0.5s 2.5s; | |
} | |
@keyframes fadeIn { | |
from {bottom: 0; opacity: 0;} | |
to {bottom: 30px; opacity: 1;} | |
} | |
@keyframes fadeOut { | |
from {bottom: 30px; opacity: 1;} | |
to {bottom: 0; opacity: 0;} | |
} | |
@-webkit-keyframes fadeIn { | |
from {bottom: 0; opacity: 0;} | |
to {bottom: 30px; opacity: 1;} | |
} | |
@-webkit-keyframes fadeOut { | |
from {bottom: 30px; opacity: 1;} | |
to {bottom: 0; opacity: 0;} | |
} | |
#toaster { | |
position: fixed; | |
visibility: hidden; | |
padding: 20px; | |
background: #333; | |
color: #FFF; | |
text-align: center; | |
border: 1px solid #333; | |
min-width: 250px; | |
margin-left: -125px; | |
left: 50%; | |
bottom: 30px; | |
border-radius: 2px; | |
z-index: 1; | |
} | |
</style> | |
<script> | |
// function triggers on click of button | |
function trigger(){ | |
var toastNotify = document.getElementById('toaster'); | |
// add classname to show the toast notify div | |
toastNotify.className = "show"; | |
// hide it automatically after 3s | |
setTimeout(function(){ | |
toastNotify.className = toastNotify.className.replace("show",""); | |
}, 3000); | |
} | |
<\/script> | |
</head> | |
<body> | |
<button class="btn" id="toastNotifyTrigger" onclick="trigger()">Trigger toast</button> | |
<div id="toaster" class="toast">You have 1 new friend request</div> | |
</body> | |
</html> | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A toast notification