<html>
<head>
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style type="text/css">
.simple-alert{display:block;position:fixed;z-index:7000;text-align:center;display:none}.simple-alert-span{display:inline-block;border-radius:5px;color:#fff;font-size:18px;line-height:25px;padding:7px 14px;margin:0 20px;background-color:#313131}.simpleAlertIn,.simpleAlertOut{animation-duration:.5s;animation-timing-function:ease;animation-fill-mode:both;backface-visibility:visible !important;animation-duration:.5s;animation-timing-function:ease;animation-fill-mode:both;backface-visibility:visible !important;animation-duration:.5s;animation-timing-function:ease;animation-fill-mode:both;backface-visibility:visible !important;animation-duration:.5s;animation-timing-function:ease;animation-fill-mode:both;backface-visibility:visible !important;animation-duration:.5s;animation-timing-function:ease;animation-fill-mode:both;backface-visibility:visible !important}.simpleAlertIn{animation-name:simpleAlertIn;animation-name:simpleAlertIn;animation-name:simpleAlertIn;animation-name:simpleAlertIn;animation-name:simpleAlertIn}.simpleAlertOut{animation-name:simpleAlertOut;animation-name:simpleAlertOut;animation-name:simpleAlertOut;animation-name:simpleAlertOut;animation-name:simpleAlertOut}@keyframes simpleAlertIn{0%{transform:perspective(400px) rotateX(90deg);opacity:0}40%{transform:perspective(400px) rotateX(-10deg)}70%{transform:perspective(400px) rotateX(10deg)}100%{transform:perspective(400px) rotateX(0deg);opacity:1}}@keyframes simpleAlertOut{0%{transform:perspective(400px) rotateX(0deg);opacity:1}100%{transform:perspective(400px) rotateX(90deg);opacity:0}}@-webkit-keyframes simpleAlertIn{0%{transform:perspective(400px) rotateX(90deg);opacity:0}40%{transform:perspective(400px) rotateX(-10deg)}70%{transform:perspective(400px) rotateX(10deg)}100%{transform:perspective(400px) rotateX(0deg);opacity:1}}@-webkit-keyframes simpleAlertOut{0%{transform:perspective(400px) rotateX(0deg);opacity:1}100%{transform:perspective(400px) rotateX(90deg);opacity:0}}@-ms-keyframes simpleAlertIn{0%{transform:perspective(400px) rotateX(90deg);opacity:0}40%{transform:perspective(400px) rotateX(-10deg)}70%{transform:perspective(400px) rotateX(10deg)}100%{transform:perspective(400px) rotateX(0deg);opacity:1}}@-ms-keyframes simpleAlertOut{0%{transform:perspective(400px) rotateX(0deg);opacity:1}100%{transform:perspective(400px) rotateX(90deg);opacity:0}}@-moz-keyframes simpleAlertIn{0%{transform:perspective(400px) rotateX(90deg);opacity:0}40%{transform:perspective(400px) rotateX(-10deg)}70%{transform:perspective(400px) rotateX(10deg)}100%{transform:perspective(400px) rotateX(0deg);opacity:1}}@-moz-keyframes simpleAlertOut{0%{transform:perspective(400px) rotateX(0deg);opacity:1}100%{transform:perspective(400px) rotateX(90deg);opacity:0}}@-o-keyframes simpleAlertIn{0%{transform:perspective(400px) rotateX(90deg);opacity:0}40%{transform:perspective(400px) rotateX(-10deg)}70%{transform:perspective(400px) rotateX(10deg)}100%{transform:perspective(400px) rotateX(0deg);opacity:1}}@-o-keyframes simpleAlertOut{0%{transform:perspective(400px) rotateX(0deg);opacity:1}100%{transform:perspective(400px) rotateX(90deg);opacity:0}}
*{
margin: 0px;
padding: 0px;
background: transparent;
border: 0px;
outline: none;
box-shadow: none;
border-radius: 0px;
}
body {
background-color: #e1e1e1;
padding: 50px 0px;
font-family: "lucida sans unicode", "lucida grande";
font-style: 16px;
color: #212121;
touch-callout: none;
}
#main_title {
position: relative;
font-size: 24px;
line-height: 30px;
text-align: center;
font-weight: bold;
color: #515151;
padding-bottom: 230px;
}
.button{
position: relative;
margin: 20px auto;
padding: 5px;
width: 250px;
height: 40px;
line-height: 40px;
text-align: center;
color: #e1e1e1;
font-size: 24px;
background-color: #355368;
border-radius: 5px;
cursor: pointer;
}
.button:hover{
color: #f1f1f1;
background-color: #273138;
}
.custom{
background-color: #7A3220;
color: #f1f1f1;
}
</syle>
</head>
<body>
<div id="main_title">
Simple alert with CSS3 animation by Wei Jia
</div>
<div id="alert" class="button">default Alert</div>
<div id="warn" class="button">cunstom Alert</div>
<script>
(function($){var body=$("body"),win=$(window),t1,t2,t3,span=document.createElement('span'),text_span=$(span),alert=$(document.createElement('div')),position=function(_alert){_alert.width(win.width()).css("top",win.height()*0.2);},remove=function(){alert.hide();text_span.removeClass("simpleAlertIn simpleAlertOut").removeClass("custom");},alertIn=function(text,param){var time=1500;remove();clearTimeout(t1);clearTimeout(t2);clearTimeout(t3);t3=setTimeout(function(){if(param)
{if(param.time)
{time=param.time;}
if(param.class)
{text_span.addClass(param.class);}}
alert.show();text_span.addClass("simpleAlertIn").html(text);t1=setTimeout(function(){text_span.addClass("simpleAlertOut");t2=setTimeout(function(){remove();},600);},time+600);},1);};alert.addClass('simple-alert').append(span);text_span.addClass('simple-alert-span')
position(alert);body.prepend(alert);$.alert=function(text,param){alertIn(text,param);};win.resize(function(){position(alert);});})($);
</script>
</body>
</html>
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |