@@ -0,0 +1,163 @@
<!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 : 960 px ;
margin : 0 auto ;
padding : 0 ;
}
* {
box - sizing : border - box ;
}
.btn {
padding : 15 px 30 px ;
color : #FFF;
text - align : center ;
background : #4 CAF50 ;
border : 0 ;
cursor : pointer ;
font - family : Verdana , sans - serif ;
font - size : 15 px ;
margin : 10 px ;
text - decoration : none ;
display : inline - block ;
}
.show {
visibility : visible ! important ;
- webkit - animation : fadeIn 0.5 s , fadeOut 0.5 s 2.5 s ;
animation : fadeIn 0.5 s , fadeOut 0.5 s 2.5 s ;
}
@keyframes fadeIn {
from { bottom : 0 ; opacity : 0 ; }
to { bottom : 30 px ; opacity : 1 ; }
}
@keyframes fadeOut {
from { bottom : 30 px ; opacity : 1 ; }
to { bottom : 0 ; opacity : 0 ; }
}
@- webkit - keyframes fadeIn {
from { bottom : 0 ; opacity : 0 ; }
to { bottom : 30 px ; opacity : 1 ; }
}
@- webkit - keyframes fadeOut {
from { bottom : 30 px ; opacity : 1 ; }
to { bottom : 0 ; opacity : 0 ; }
}
#toaster {
position : fixed ;
visibility : hidden ;
padding : 20 px ;
background : #333 ;
color : #FFF;
text - align : center ;
border : 1 px solid #333 ;
min - width : 250 px ;
margin - left : - 125 px ;
left : 50 % ;
bottom : 30 px ;
border - radius : 2 px ;
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 >