JSFiddle - React, Tailwind, and code Playground
by veloper
HTML
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<body>
<!-- Optional theme -->
<section id="options">
<p id="show-buttons">
<button class="show-front">Show 1</button>
<button class="show-back">Show 2</button>
<button class="show-right">Show 3</button>
<button class="show-left">Show 4</button>
<button class="show-top">Show 5</button>
<button class="show-bottom">Show 6</button>
</p>
<p>
<button id="toggle-backface-visibility">Toggle Backface Visibility</button>
</p>
</section>
<section class="container">
<div id="cube" class="show-front">
<figure class="front">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</figure>
<figure class="back"> <div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"...
CSS
section, footer, nav {
display: block;
}
body {
font-family: 'Helvetica Neue', Arial, sans-serif;
-webkit-text-size-adjust: none;
color: #333;
}
#options {
position: relative;
z-index: 100;
margin-bottom: 60px;
}
.container {
width: 650px;
height: 650px;
position: relative;
margin: 0 auto 40px;
}
#cube {
width: 650px;
height: 650px;
position: absolute;
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
-o-transform-style: preserve-3d;
transform-style: preserve-3d;
-webkit-transition: -webkit-transform .75s;
-moz-transition: -moz-transform 1s;
-o-transition: -o-transform 1s;
transition: transform 1s;
}
.modal-body { height: 400px }
#cube figure {
display: block;
position: absolute;
width: 650px;
height: 650px;
background:white;
}
#cube .front {
-webkit-transform: translateZ( 325px );
-moz-transform: translateZ( 100px );
-o-transform: translateZ( 100px );
transform: translateZ( 100px );
}
#cube .back {
-webkit-transform: rotateX( -180deg ) translateZ( 325px );
-moz-transform: rotateX( -180deg ) translateZ( 100px );
-o-transform: rotateX( -180deg ) translateZ( 100px );
transform: rotateX( -180deg ) translateZ( 100px );
}
#cube .right {
-webkit-transform: rotateY( 90deg ) translateZ( 325px );
-moz-transform: rotateY( 90deg ) translateZ( 100px );
-o-transform: rotateY( 90deg ) translateZ( 100px );
transform: rotateY( 90deg ) translateZ( 100px );
}
#cube .left {
-webkit-transform: rotateY( -90deg ) translateZ( 325px );
-moz-transform: rotateY( -90deg ) translateZ( 100px );
-o-transform: rotateY( -90deg ) translateZ( 100px );
transform: rotateY( -90deg )...
JavaScript
// ======================= DOM Utility Functions from PastryKit =============================== //
// Sure, we could use jQuery or XUI for these,
// but these are concise and will work with plain vanilla JS
Element.prototype.hasClassName = function (a) {
return new RegExp("(?:^|\\s+)" + a + "(?:\\s+|$)").test(this.className);
};
Element.prototype.addClassName = function (a) {
if (!this.hasClassName(a)) {
this.className = [this.className, a].join(" ");
}
};
Element.prototype.removeClassName = function (b) {
if (this.hasClassName(b)) {
var a = this.className;
this.className = a.replace(new RegExp("(?:^|\\s+)" + b + "(?:\\s+|$)", "g"), " ");
}
};
Element.prototype.toggleClassName = function (a) {
this[this.hasClassName(a) ? "removeClassName" : "addClassName"](a);
};
...