<header>
	<h1>Newsletter Signup 3D Form</h1>
</header>
<main>
  <div class="newsletter-form">
    <form>
      <div class="cubeside">
        <p class="cuboid-text">Subscribe to the newsletter</p>
      </div>
      <div class="cubeside">
        <button type="submit" class="btn-submit icon-submit"><span>Subscribe</span></button>
        <input type="email" id="email" class="cuboid-text" placeholder="Email Address" autocomplete="off" required>
        <input type="submit" id="submit">
      </div>
      <div class="cubeside">
        <p class="cuboid-text loader">Just a moment…</p>
      </div>
      <div class="cubeside">
        <button type="reset" class="btn-reset icon-reset"><span>Comenzar de nuevo</span></button>
        <p class="cuboid-text success">Thank you! We'll be in touch</p>
      </div>
    </form>
  </div>
</main>
<footer>
	<small>Forked from: <a href="http://thecodeplayer.com/walkthrough/single-input-3d-form">Single Input 3D</a></small>
</footer>



@import "bourbon";

$black: #212121;
$blue: #0089AB;
$green: #A2CB4A;
$orange: #E57400;
$white: #f8f8f8;
$blackdotted: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAE0lEQVQIW2NkYGD4D8SMjEACDAAOKQEDKKNmJgAAAABJRU5ErkJggg==) repeat;

body {
	background: #333 $blackdotted;
	padding-top: 150px;
	font: normal 100%/1.5 Arial; color: white; text-align: center;
}

a {
  color: white;
}

[class^="icon-"], [class*=" icon-"] {
	speak: none;
	font-style: normal;
	font-weight: normal;
	font-variant: normal;
	text-transform: none;
	line-height: 1;

	/* Better Font Rendering =========== */
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

.icon-reset:before {
	content: "↻";
}
.icon-submit:before {
	content: "⇾";
}

.newsletter-form {
	margin: 0 auto 2em;
	width: 400px;
	//this also makes .newsletter-form a container for absolutely positioned descendants
	@include perspective(1000px);

	form {
		//prevent height collapse as children are absolutely positioned
		height: 40px;
		//counter translate
		@include transform(translateZ(-20px));
		//propogate 3d space for children
		@include transform-style(preserve-3d);
		//for smooth animations
		@include transition(all 0.35s);

		//the form will have 4 states/classes(default+3) for rotation
		&:hover,
		&.ready {@include transform(translateZ(-20px) rotateX(90deg));}
		&.loading {@include transform(translateZ(-20px) rotateX(180deg));}
		&.complete {@include transform(translateZ(-20px) rotateX(270deg));}
	}
}

.cubeside {
	left: 0;
	overflow: hidden;
	position: absolute;
	top: 0;
	width: 100%;

	p {
		margin: 0;
		padding: 0;
	}

	//3D transforms. Each face will be rotated in multiples of -90deg and moved 20px(half of their 40px height) out
	&:nth-child(1) {@include transform(rotateX(0deg) translateZ(20px));}
	&:nth-child(2) {@include transform(rotateX(-90deg) translateZ(20px));}
	&:nth-child(3) {@include transform(rotateX(-180deg) translateZ(20px));}
	&:nth-child(4) {@include transform(rotateX(-270deg) translateZ(20px));}
}

//faces
.cuboid-text {
	//each face will be 40px high
	height: 40px;
	line-height: 40px;
	background: $orange;

	&.success {
		background: shade($green, 20%);
	}
}

.loader {
	background: $blue;
	@include animation(phase 1s infinite);
}

//Lets create a pulsating animation for the loader face
@include keyframes(phase) {
	50% {
		background: shade($blue, 40%);
	}
}

#email {
	background: white;
	border: 0 none;
	color: lighten($black, 20%);
	display: block;
	font: inherit;
	outline: none;
	padding: 0 10px;
	text-align: left;
	width: 100%;
	@include box-sizing(border-box);
}

#submit {
	display: none;
}

.btn-submit,
.btn-reset {
	background: transparent;
	border: none;
	cursor: pointer;
	line-height: 40px;
	outline: none;
	padding: 0 10px;
	position: absolute;
	right: 0;
	top: 0;
	@include transition(all 0.5s);
	@include size( 40px );

	span {
		@include hide-text;
	}
}

//.active = when the user is typing something
.icon-submit.active {
	color: lighten($black, 40%);
}

.icon-reset {
	color: rgba(255, 255, 255, 0.5);
	font-size: 14px;

	&:hover {
		color: $white;
	}
}
//jQuery time

var complete = function () {
  $('.newsletter-form form').removeClass('loading').addClass('complete');
};

//add '.ready' to form when user focuses on it
$('#email').focus( function() {
  $('.newsletter-form form').addClass('ready');
});

//remove '.ready' when user blurs away but only if there is no content
$('#email').blur( function() {
  if($(this).val() === '')
    $('.newsletter-form form').removeClass('ready');
});

//If the user is typing something make the arrow .active
$('#email').keyup( function() {
  //this adds .active class only if the input has some text
  $('.icon-submit').toggleClass('active', $(this).val().length > 0);
});

//on form submit remove .ready and add .loading to the form
$('.newsletter-form form').submit( function() {
  $(this).removeClass('ready').addClass('loading');
  //finish loading in 3s
  setTimeout(complete, 3000);
  //prevent default form submisson
  return false;
});

//reset/refresh functionality
$('.icon-reset').click( function() {
  $('.newsletter-form form').removeClass('complete');
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. //cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js