@import url(http://fonts.googleapis.com/css?family=Dosis);
* {margin: 0; padding: 0;}
body {
background: hsl(120, 40%, 60%);
padding-top: 150px;
font: normal 18px 'Dosis';
color: white;
text-align: center;
}
/*general styles*/
h1 {font-weight: normal; font-size: 36px; margin-bottom: 75px;}
.fun-cube i {transform: scale(10); opacity: 0.1;}
#cuboid {
width: 400px; margin: 0 auto;
/*this also makes #cuboid a container for absolutely positioned descendants*/
perspective: 1000px;
}
#cuboid form {
/*counter translate*/
transform: translateZ(-20px);
/*propogate 3d space for children*/
transform-style: preserve-3d;
/*prevent height collapse as children are absolutely positioned*/
height: 40px;
/*for smooth animations*/
transition: all 0.35s;
}
/*faces*/
.cuboid-text {
/*each face will be 40px high*/
line-height: 40px; height: 40px;
background: hsl(120, 40%, 20%);
}
.loader {
background: hsl(120, 40%, 30%);
animation: phase 1s infinite;
}
/*Lets create a pulsating animation for the loader face*/
@keyframes phase {
50% {background: hsl(120, 70%, 30%);}
}
#email {
background: white; outline: none; border: 0 none;
font: inherit; text-align: left; color: hsl(120, 40%, 30%);
display: block; width: 100%; padding: 0 10px;
box-sizing: border-box;
}
#submit {display: none;}
.submit-icon, .reset-icon {
position: absolute; top: 0; right: 0;
color: rgba(0, 0, 0, 0.25);
line-height: 40px; padding: 0 10px;
/*smooth transitions when user activates input and types something*/
transition: all 0.5s;
/*to make the icons feel like buttons*/
cursor: pointer;
}
/*.active = when the user is typing something*/
.submit-icon.active {color: hsl(120, 40%, 30%);}
.reset-icon {color: rgba(255, 255, 255, 0.25); font-size: 14px;}
#cuboid div {position: absolute; top: 0; left: 0; width: 100%;}
/*3D transforms. Each face will be rotated in multiples of -90deg and moved 20px(half of their 40px height) out*/
#cuboid div:nth-child(1) {transform: rotateX(0deg)...
JavaScript
// From http://thecodeplayer.com/walkthrough/single-input-3d-form
//add '.ready' to form when user focuses on it
$("#email").focus(function(){
$("#cuboid form").addClass("ready");
})
//remove '.ready' when user blus away but only if there is no content
$("#email").blur(function(){
if($(this).val() == "")
$("#cuboid form").removeClass("ready");
})
//If the user is typing something make the arrow green/.active
$("#email").keyup(function(){
//this adds .active class only if the input has some text
$(".submit-icon").toggleClass("active", $(this).val().length > 0);
})
//on form submit remove .ready and add .loading to the form
$("#cuboid form").submit(function(){
$(this).removeClass("ready").addClass("loading");
//finish loading in 3s
setTimeout(complete, 3000);
//prevent default form submisson
return false;
})
function complete()
{
$("#cuboid form").removeClass("loading").addClass("complete");
}
//reset/refresh functionality
$(".reset-icon").click(function(){
$("#cuboid form").removeClass("complete");
})
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.