JSFiddle - React, Tailwind, and code Playground
by kachibito
HTML
<ul id="menu">
<li><a href="" name="home">Blue</a></li>
<li><a href="" name="about">Red</a></li>
<li><a href="" name="services">Yellow</a></li>
</ul>
<div id="home">
<div class="content">
<p>blue</p> </div>
</div>
<div id="about">
<div class="content">
<p>red</p>
</div>
</div>
<div id="services">
<div class="content">
<p>yellow</p>
</div>
</div>
CSS
body {
padding: 0;
margin: 0;
background: #000;
overflow: hidden;
}
body > div {
position: absolute;
top: 0; left: 0;
}
/* MENU STUFF ================= */
#menu {
position: absolute;
z-index: 12;
list-style: none;
padding: 0; margin: 0;
top: 20px;
left: 20px;
background: #fff;
padding: 10px;
}
.current {
background: black;
color: #fff !important;
border-bottom: 1px solid #000 !important;
}
.current:hover {
color: #fff;
}
#menu li a {
border-bottom: 1px solid #eee;
font-family: Arial, sans-serif;
width: 250px;
padding: 10px;
display: block;
text-decoration: none;
text-transform: uppercase;
color: #000;
}
#menu li a:hover {
background: #000;
color: #fff;
border-bottom: 1px solid #000;
}
/* END MENU STUFF =========================== */
.content {
position: absolute;
top: 0;
left: 0;
display: none;
z-index: 11;
}
.before-slices, #home .after-slices {
display: inline-block;
height: inherit;
text-transform: lowercase;
}
#home .slice {
display: inline-block;
position: relative;
background: blue;
z-index: inherit;
box-shadow: 0px 0px 20px rgba(0,0,0,0.1);
font-weight: bold;
}
#about .slice {
background: red;
}
#services .slice {
background-color: yellow;
}
.endShadow {
box-shadow: none !important;
}
.slices, .vertical, .horizontal {
width: inherit;
height: inherit;
}
.vertical .slice {
height: inherit;
top: 100%;
width: 90px;
}
.horizontal .slice {
position: absolute;
top: 0;
right: 100%;
width: inherit;
height: 90px;
z-index: inherit;
box-shadow: 0px 0px 20px rgba(0,0,0,0.1);
font-weight: bold;
text-transform: capitalize;
}
.slice {
position: absolute;
text-transform: lowercase;
}
.left-slices, .right-slices {
height: inherit;
width: 50%;
display: inline-block;
}
.left-slices .slice,...
JavaScript
$(document).ready(function () {
// Marks whether an animation is currently running
var animationsRunning = 0;
// Initial window width
var initialWidth = $(window).width();
// Function wrapping code.
var wrapFunction = function (fn, context, params) {
return function () {
fn.apply(context, params);
};
};
// Global function queue
var funqueue = [];
// An array of the items to animate
var objects = {
'home': 'vertical',
'about': 'horizontal',
'services': 'slide'
}
function generateSlice(mainContainer, direction) {
// Get some core variables
var direction = direction
var mainContainer = $('#' + mainContainer);
var sliceWidth = 90;
// Get the height and width of the window currently
var height = screen.height;
var width = screen.width;
// Change the width and height of the container to the height and width of the window
mainContainer.css({
'width': width + 'px',
'height': height + 'px'
});
//Add a container called 'slices' to every container.
if (mainContainer.find('.slices').length < 1) {
mainContainer.append('<div class="slices"></div>');
}
// An incremental variable
var incr = 0;
var theShadow = $(mainContainer).find('endShadow');
// Determine which style to apply
if (direction == 'vertical') {
mainContainer.addClass('vertical');
// If vertical, we need to add vertical slices.
if (mainContainer.find('.vertical').length < 1) {
mainContainer.children('.slices').append('<div class="vertical"></div>');
}
// Divide the screen width by the slice width to get the number of slices.
...