<html>
<head>
<link href="//cdnjs.cloudflare.com/ajax/libs/foundation/5.0.3/css/normalize.min.css" rel="stylesheet" type="text/css" />
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="//cdnjs.cloudflare.com/ajax/libs/foundation/5.0.3/css/foundation.min.css" rel="stylesheet" type="text/css" />
<script src="//cdnjs.cloudflare.com/ajax/libs/foundation/5.0.3/js/vendor/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/foundation/5.0.3/js/foundation.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<div id="site-wrapper">
<div id="site-canvas">
<div id="site-menu">
<a href="#" class="toggle-nav" style="color: pink; font-size: 20px;"><i class="fa fa-times"></i></a>
<h2>My Menu</h2>
<p class="lead">Put any HTML you want here.</p>
<p>Style it however you want.</p>
<ul>
<li>Free to scroll up and down</li>
<li>But not left and write</li>
</ul>
</div>
<a href="#" class="toggle-nav button btn-lg btn-success" id="big-sexy"><i class="fa fa-bars"></i> Toggle Nav</a>
<h1 class="text-center">Off Canvas Menu Tutorial</h1>
<p class="lead text-center">Basic demo showing how to easily implement an Off Canvas Menu by <a href="http://scotch.io/tutorials/off-canvas-menus-with-css3-transitions-and-transforms">scotch.io</a>.</p>
</div>
</div>
</body>
</html>
/*
* Uses Font Awesome and Bootstrap 3
* Both aren't required for this demo
*/
#site-wrapper {
position: relative;
overflow: hidden;
width: 100%;
height: 5000px; /* Temp: Simulates a tall page. */
}
#site-canvas {
width: 100%;
height: 100%;
position: relative;
transform: translateX(0);
transform: translateX(0);
transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
transition: 300ms ease all;
transition: 300ms ease all;
backface-visibility: hidden;
backface-visibility: hidden;
padding: 5% 0; /* Temp: Just spacing. */
}
.show-nav #site-canvas {
transform: translateX(300px);
transform: translateX(300px);
transform: translate3d(300px, 0, 0);
transform: translate3d(300px, 0, 0);
}
#site-menu {
width: 300px;
height: 100%;
position: absolute;
top: 0;
left: -300px;
background: #428bca;
padding: 15px;
}
/* Just styles... Not relevant to demo */
body {
box-shadow: inset 0 0 100px rgba(0,0,0,.5);
background-color: #333;
color: #fff;
}
#big-sexy {
display: block;
width: 300px;
margin: 0 auto;
font-size: 40px;
font-weight: 300;
}
/*
* Uses jQuery!!!!111one
*/
/*====================================
= ON DOM READY =
====================================*/
$(function() {
// Toggle Nav on Click
$('.toggle-nav').click(function() {
// Calling a function in case you want to expand upon this.
toggleNav();
});
});
/*========================================
= CUSTOM FUNCTIONS =
========================================*/
function toggleNav() {
if ($('#site-wrapper').hasClass('show-nav')) {
// Do things on Nav Close
$('#site-wrapper').removeClass('show-nav');
} else {
// Do things on Nav Open
$('#site-wrapper').addClass('show-nav');
}
//$('#site-wrapper').toggleClass('show-nav');
}
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. |