<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="https://rawgithub.com/WickyNilliams/enquire.js/master/dist/enquire.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<header>
<h2>Site Title</h2>
<p>tag line</p>
</header>
<div id="page">
<h1>Page title</h1>
<p>Lorem ipsum@dolor.com sit amet, consectetur adipiscing elit. Nunc pharetra luctus mi, sollicitudin ultrices lacus iaculis sed. Nam aliquam, tortor id sodales scelerisque, est mauris adipiscing nunc, a tincidunt tortor elit eget quam. Fusce sagittis arcu ut urna egestas luctus. Aliquam erat volutpat. Suspendisse ut turpis mi. Nulla facilisi. </p>
</div>
<aside>
<section data-respond='{"query":"screen and (max-width: 600px)", "match": { "target": "header", "method": "appendTo"}, "unmatch": "auto"}'>
<h3>Search</h3>
<p>Lorem ipsum sit amet, consectetur adipiscing elit.</p>
</section>
<section data-respond='{"query":"screen and (max-width: 680px)", "match": { "target": "footer", "method": "appendTo"}, "unmatch": { "target": "aside", "method": "appendTo"}}'>
<h3>Links</h3>
<p>Lorem ipsum sit amet, consectetur adipiscing elit.</p>
</section>
<section>
<h3>News</h3>
<p>Lorem ipsum sit amet, consectetur adipiscing elit.</p>
</section>
</aside>
<footer>
<p>Copyright stuff</p>
</footer>
</body>
</html>
* {
margin: 0;
box-sizing: border-box;
box-sizing: border-box;
box-sizing: border-box;
}
body > * {
padding: 20px;
}
section {
margin: 10px 0 ;
}
header {
background: #105b63;
color: #fff;
}
#page {
background: #fffad5;
color: #000;
float: right;
width: 80%
}
aside {
background: #ffd34e;
float: left;
width: 20%
}
footer {
background: #bd4932;
clear: both;
}
(function($) {
$(document).ready(function() {
var $this,
data,
options,
allowedMethods = ['appendTo','prependTo','insertAfter','insertBefore'];
$("[data-respond]").each(function(){
$this = $(this),
data = $this.data("respond");
options = {};
// check we have object
/*if(typeof data !== 'object'){
data = eval(data);
}*/
if(data.match){
if($.inArray(data.match.method, allowedMethods) > -1){
options.match = function() {
if(data.match.method == 'insertAfter'){
if($this[0] == $(data.match.target).next()[0]){
return;
}
}
if($(data.match.target).length){
$this[data.match.method](data.match.target);
}
}
}
}//match
if(data.unmatch){
if(data.unmatch == 'auto'){
data.unmatch = {};
// a) insert after
if($this.prev().length){
data.unmatch.target = $this.prev();
data.unmatch.method = 'insertAfter';
} else if($this.next().length){
// c) insert before
data.unmatch.target = $this.next();
data.unmatch.method = 'insertBefore';
} else {
// d) append to parent
data.unmatch.target = $this.parent();
data.unmatch.method = 'appendTo';
}
if($.inArray(data.unmatch.method, allowedMethods) > -1){
options.unmatch = function() {
$this[data.unmatch.method](data.unmatch.target);
}
}
} else {
// Manually set unmatch
if($.inArray(data.unmatch.method, allowedMethods) > -1){
options.unmatch = function() {
if($(data.unmatch.target).length){
$this[data.unmatch.method](data.unmatch.target);
}
}
}
}
}//unmatch
enquire.register(data.query, options);
});
});
})(jQuery);
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. |