/*
This defines the workspace where i place the demo.
*/
#container {
text-align: left;
background: #FFF;
width: 865px;
margin: 20px auto;
padding: 20px;
border-left: 1px solid #CCC;
border-right: 1px solid #CCC;
-moz-box-shadow: 0px 0px 10px #BBB;
-webkit-box-shadow: 0px 0px 10px #BBB;
box-shadow: 0px 0px 10px #BBB;
}
/*
It defines the layer which will cover the site once the
floating window is showed.
*/
#darkOverlay{
background: none repeat scroll 0 0 rgba(255, 255, 255, 0.8);
cursor: auto;
display: none; /*hidding if there's no call */
height: 100%;
left: 0;
overflow-y: auto;
position: fixed;
top: 0;
width: 100%;
z-index: 100; /*over everything */
}
/*
We want the content to be center...
*/
#floatWrap{
margin: 0 auto;
position: static;
width: 878px;
z-index: 102;
}
/*
Defining the window wrap...
*/
#floatContent{
float: left;
background: white;
box-shadow: 0 3px 8px rgba(34, 25, 25, 0.4);
z-index: 101; /*over the overlay*/
margin:80px 0 80px 0;
position:relative;
}
/*
Defining the window...
*/
#mainFloat{
float: left;
margin: 0;
width: 900px;
min-height: 500px;
position: relative;
/*witht his background we divide visually
the space*/
background: url('imgs/bgFloat.gif') repeat-y #fff;
}
/*
Adding the X for closing the window
*/
.close{
position: absolute;
top: -15px;
right: -15px;
width: 30px;
height: 30px;
background: transparent url('imgs/fancybox.png') -40px 0px;
cursor: pointer;
z-index: 1103;
display: inline;
}
/* Left tabs menu*/
#menuLeft{
float:left;
width:223px;
margin:90px 0 0 0;
}
#menuLeft ul{
margin: -10px 0 0 0;
float: left;
list-style: none outside none;
padding: 0;
width: 100%;
}
#menuLeft li{
border-bottom: 1px solid #DDD;
float: left;
padding: 0 0 0 12px;
width: 190px;
margin: 0 10px 0 10px;
}
#menuLeft ul li a{
color: #333;
display: block;
padding: 18px 0;
text-decoration: none;
width: 204px;
font-size:1.2em;
}
#menuLeft...
JavaScript
$(document).ready(function(){
/*
We use this to hide the floating window in case they click outside it.
As html will be 'everything', we will use then an stopPropagation event.
*/
$('html, .close').click(function(){
$('.selection').hide();
$('#darkOverlay').hide();
$("body").css("overflow", "visible");
});
/*
Here we use the stopPropagation event in order to prevent hidding the
floating window when we click anywhere inside the #mainFloat element.
*/
$("#mainFloat").click(function(event){
event.stopPropagation();
});
/*
Adding the option to hide the windows by pressing the 'escape' (ESC)
key with the keyboard.
*/
$(document).keyup(function(e) {
if (e.keyCode == 27) {
$('#darkOverlay').hide();
$("body").css("overflow", "auto");
}
});
/*
Clicking over the .floatMenu selector, we will show the floating window.
*/
$('.floatMenu').click(function(event){
// Showing the floating window
$('#darkOverlay').show();
// Hidding the background page scroll
$("body").css("overflow", "hidden");
/*default content for the first tab. (you could use
JSON, .load, append... whatever you want */
$("#infoContent").html('Hello world');
// When clicking on the left tab menu...
$('.floatCategory').click(function() {
// Chaning the active tab...
$(this).parent().addClass("active").siblings().removeClass('active');
//We have to know in which tab the user has clicked
//so we take the attribute 'data-content' as an identifier of the tab
var content = $(this).attr('data-content');
/* Here you could do whatever you want, getting
info from JSON, using the .load function... having fun!!*/
$("#infoContent").html(content);
});
/* In order to prevent hidding the floating window, as we are on the 'html' element.
We have to stop the click event propagation so it won't reach 'html' */
event.stopPropagation();
});
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.