<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<div id="gal_container">
<div id="labeler"></div>
<ul id="labels">
<li>Discover </li>
<li>Collaborate </li>
<li>Create </li>
<li>Develop </li>
<li>Launch </li>
<li>Maintain </li>
<li>Learn </li>
</ul>
<div id="pages">
<div>
<h2>content 1</h2>
</div>
<div>
<h2>content 2</h2>
</div>
<div>
<h2>content 3</h2>
</div>
<div>
<h2>content 4</h2>
</div>
<div>
<h2>content 5</h2>
</div>
<div>
<h2>content 6</h2>
</div>
<div>
<h2>content 7</h2>
</div>
</div>
<div id="prev"></div>
<div id="next"></div>
</div>
</body>
</html>
body{background:#4A1816;color:#fff;font-family:Arial;}
#gal_container{
position:relative;
margin:0 auto;
width:354px;
}
/* ---------- */
/* ---------- */
#labeler{
position:absolute;
left:0px;
top:-40px;
}
#labels{
position:relative;
height:4px;
padding:0;
list-style:none;
background:#f10;
margin-top:50px; /* space for labeler */
}
#labels li{
margin:-7px 38px 0 0;
width:12px;
height:12px;
padding-left:-7px;
border:3px solid #f10;
background:#411;
border-radius:10px;
float:left;
text-indent:-9000px;
}
#labels li:last-child{
margin-right:0px;
}
#labels li.select{
background:#fff;
box-shadow:inset 0 0 0 3px #411;
box-shadow:inset 0 0 0 3px #411;
}
/* ---------- */
#pages{
background:#000;
overflow:hidden;
position:relative;
width:354px;
height:354px;
border-radius:8px;
border-radius:8px;
}
#pages > div{
position:absolute;
top:0px;
height:100%;
width:300px;
background:#ad1000;
padding:27px;
}
/* ---------- */
#prev, #next{
cursor:pointer;
position:absolute;
background:#fff;
width:50px;
height:50px;
top:168px;
border-radius:40px;
border-radius:40px;
opacity:0.5;
}
#prev:hover, #next:hover{
opacity:0.8;
}
#prev{
left:-25px;
}
#next{
right:-25px;
}
$(function(){
var $lab_UL = $('#labels'),
$lab_LI = $lab_UL.find('li'),
$labeler = $('#labeler'),
$page = $('#pages').find('div'),
pagesN = $page.length;
c = 0; // curr. counter
$page.hide().eq( c ).show();
$lab_LI.eq( c ).addClass('select');
// functions
function labelize(){
var liPos = $lab_LI.eq( c ).position().left;
$labeler.text( $lab_LI.eq( c ).text() )
.css({ left: - ($labeler.width()/2) + liPos });
}
function selectBtn(){
$lab_LI.removeClass('select').eq( c ).addClass('select');
}
function changePages(){
$page.hide().eq( c ).fadeTo(300,1);
}
// run some on DOM ready
labelize();
selectBtn();
$('#prev, #next').click(function(){
// logic //
var myID = this.id=='next' ? c++ : c--;
c= c===-1? pagesN-1 : c%pagesN ;
// execute our functions
labelize();
selectBtn();
changePages();
});
});
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. |