Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
<!-- 
Card design: https://www.behance.net/gallery/16575373/The-Evil-Deck-Revised
 -->

	<div class="wrapper">
		<ul class="slide-container">
			<li class="slide">
				<img class="flip-card" src="https://dl.dropboxusercontent.com/s/9hh72fw494unrqa/card-9a.jpg" alt="">
				<img class="static-img" src="https://dl.dropboxusercontent.com/s/itmegdckvtj834r/card-9b.png" alt="">
			</li>
			<li class="slide">
				<img class="flip-card" src="https://dl.dropboxusercontent.com/s/5wjrkmam4y4er6c/card-2a.jpg" alt="">
				<img class="static-img" src="https://dl.dropboxusercontent.com/s/nf52qzxkx8089ow/card-2b.png" alt="">
			</li>
			<li class="slide">
				<img class="flip-card" src="https://dl.dropboxusercontent.com/s/des7orec20wg5vk/card-3a.jpg" alt="">
				<img class="static-img" src="https://dl.dropboxusercontent.com/s/b0h5u9izyeaxnxh/card-3b.png" alt="">
			</li>
			<li class="slide">
				<img class="flip-card" src="https://dl.dropboxusercontent.com/s/9rub3yy5cyp1osa/card-1a.jpg" alt="">
				<img class="static-img" src="https://dl.dropboxusercontent.com/s/mlso8zjbndxfic9/card-1b.png" alt="">
			</li>
			<li class="slide">
				<img class="flip-card" src="https://dl.dropboxusercontent.com/s/5ewq8p1m16rsncc/card-4a.jpg" alt="">
				<img class="static-img" src="https://dl.dropboxusercontent.com/s/1hkd3xu2himo3aq/card-4b.png" alt="">
			</li>
			<li class="slide">
				<img class="flip-card" src="https://dl.dropboxusercontent.com/s/494j1f4arp94ohz/card-5a.jpg" alt="">
				<img class="static-img" src="https://dl.dropboxusercontent.com/s/i8ihs4nm8r0kwwm/card-5b.png" alt="">
			</li>
			<li class="slide">
				<img class="flip-card" src="https://dl.dropboxusercontent.com/s/gt4l998qhtxjt8e/card-6a.jpg" alt="">
				<img class="static-img" src="https://dl.dropboxusercontent.com/s/2dhil7putheg53f/card-6b.png" alt="">
			</li>
			<li class="slide">
				<img class="flip-card" src="https://dl.dropboxusercontent.com/s/eq3ikntex79gwd9/card-7a.jpg" alt="">
				<img class="static-img" src="https://dl.dropboxusercontent.com/s/xhzxcv6wpm42d3r/card-7b.png" alt="">
			</li>
			<li class="slide">
				<img class="flip-card" src="https://dl.dropboxusercontent.com/s/bvigk27sj68xxfh/card-10a.jpg" alt="">
				<img class="static-img" src="https://dl.dropboxusercontent.com/s/gapu22yxp3d3mvs/card-10b.png" alt="">
			</li>
			<li class="slide">
				<img class="flip-card" src="https://dl.dropboxusercontent.com/s/w15f0b0jeoouhna/card-8a.jpg" alt="">
				<img class="static-img" src="https://dl.dropboxusercontent.com/s/2dzwn4xpdo4ncb3/card-8b.png" alt="">
			</li>
		</ul>
		<div class="pagination">
			<button class="btn-prev">Prev</button>
			<button class="btn-next">Next</button>
		</div>
	</div>

              
            
!

CSS

              
                @import "compass/reset";

$animtime: 1s;
$delay: 0.1s;
$ease: cubic-bezier(.45,0,.55,1);

body,
html {
	width: 100%;
	height: 100%;
	background-color: #ccc;
}

.wrapper {
	width: 100%;
	height: 100%;
	display: flex;
	flex-direction: row;
	margin: auto;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}

.slide-container {
	display: flex;
	flex-direction: row;
	position: relative;
	width: 436px;
	height: 608px;
}

.slide {
	position: absolute;
	width: 100%;
	height: 100%;
	transition: transform $animtime $ease;
	perspective-origin: 50% 50%;
	perspective: 800px;
	overflow: hidden;

	.flip-card {
		position: absolute;
		width: 100%;
		height: 100%;
		border-radius: 20px;
		transition: transform $animtime $ease;

		&:before {
			content: '';
			position: absolute;
			width: 100%;
			height: 100%;
			top:0;
			left: 0;
			background-color: rgba(0,0,0,0.5);
		}
	}
	.static-img {
		position: relative;
		display: block;
		z-index: 9;
	    text-align: center;
	    width: 100%;
	    top: 0%;
	    transition: transform $animtime $ease;
	}

	
	&[data-position="before"]{
		perspective-origin: 100% 50%;
		transform: translateX(-600px);

		.flip-card {
			transform: translateZ(-400px) rotateY(45deg);
			transform-origin: 100% 0%;
		}

		.static-img {
			transform: translateX(600px); // position central - neutralize parent transform
		}
	}

	&[data-position="after"]{
		perspective-origin: 0% 50%;
		transform: translateX(600px);

		.flip-card {
			transform: translateZ(-400px) rotateY(-45deg);
			transform-origin: 0% 0%;
		}

		.static-img {
			transform: translateX(-600px); // position central - neutralize parent transform
		}
	}

	&.on-stage {
		transform: translateX(0);
		z-index: 5;
		transition-delay: $delay;

		.flip-card {
			transform: rotateY(0);
			transition-delay: $delay;
		}
		.static-img {
			opacity: 1;
			transform:translateX(0);
			transition-delay: $delay;
		}

		& + .slide {
			z-index: 4;
			& + .slide {
				z-index: 3;
			}
		}

	}
}

.pagination {
	position: absolute;
	top: 50%;
	left: 0;
	width:100%;
	transform: translateY(-50%); 
	z-index: 99;


	button {
		position: absolute;
		display: block;
		width: 60px;
		height: 60px;
		background-color: rgba(0,0,0,0.8);
		color:  rgba(255,51,0,1);
		border-radius: 50%;
		border: none;
		cursor: pointer;
		transition: all 0.5s;
		font-family: 'Crimson Text', serif;
		font-size: 16px;

		&:hover {
			background-color: rgba(255,51,0,1);
			color: black;
		}
		
		&:active,
		&:focus { 
		   outline: none;
		}

		&.btn-prev {
			left: 50px;
		}
		&.btn-next {
			right: 50px;
		}

	}
}
              
            
!

JS

              
                 var  DF = DF || {};

 (function() {
	 'use strict';


	 // DOM
	 var $Window = $(window);

	 var ANIM_TIME = 1250;

	 // CONSTANTS
	 var IS_HIDDEN = 'is-hidden';

	 var KEYS = {
		 'up': 38,
		 'down': 40,
		 'left': 37,
		 'right': 39
	 };

	 // VARIABLES
	 var vh = $Window.height(),
		 vw = $Window.width(),
		 scrollDirectionNext,
		 slideTimer;




	 /****************************
	  *
	  *  Slider Constructor
	  *
	  ******************************/
	 DF.SlidePage = function(context, options) {

		var context = context || document;
		var options = options || {};

		 this.opts = {
			 ON_STAGE: 'on-stage',
			 sliderTime: 0,
			 selector: '.slide',
			 paginationSelector: ''
		 };


		 $.extend(this.opts, options);

		 this.context = context;
		 this.slides = $(this.opts.selector, context);
		 this.slideLength = this.slides.length;
		 this.scrollDirectionNext = true;
		 this.sidenavLinks = [];

		 this.init();
	 };

	 DF.SlidePage.prototype = {

		 constructor: DF.SlidePage,

		 sliderTimeoutChange: function(sliderTime) {

			 var self = this;

			 if (sliderTime) {
				 slideTimer = setInterval(function() {
					 self.changeSlides(true);
				 }, sliderTime);
			 } else {
				 clearInterval(slideTimer);
			 }
		 },

		 bindListeners: function() {

			 var self = this;
			 var $Window = $(window);


			 $Window.bind('keyup', function(e) {
				 var key = e.keyCode;

				 if (DF.canScroll) {

					 switch (key) {
						 case KEYS.up:
						 case KEYS.left:
							 self.changeSlides(false);
							 break;
						 case KEYS.down:
						 case KEYS.right:
							 self.changeSlides(true);
							 break;
					 }
					 self.sliderTimeoutChange();
				 }
			 });


			 $Window.bind('DOMMouseScroll mousewheel wheel', function(e) {
				 e.preventDefault();
				 var delta = parseInt(e.originalEvent.deltaY || e.originalEvent.detail);
				 self.handleScroll(delta);

			 });

			 $('.btn-next').bind('click',function () {
			 	 if (DF.canScroll) self.changeSlides(true);
			 });

			  $('.btn-prev').bind('click',function () {
			 	 if (DF.canScroll) self.changeSlides(false);
			 });
		 },

		 handleScroll: function(delta) {
			 var self = this;

			 if (DF.canScroll) {

				 //Animate slides - play next (directionNext = true) if scrolling is downwards
				 self.changeSlides(delta > 0);
				 self.sliderTimeoutChange();
			 }
		 },


		 changeSlides: function(directionNext) {

			 var self = this;
			 self.isAnimating = false;
			 self.endCurrPage = false;
			 self.endNextPage = false;

			 DF.canScroll = false;

			 if (self.slideLength && self.slideLength > 1) {

				 if (directionNext) {
					 if (self.currSlideIndex < self.slideLength - 1) {
						self.prevSlideIndex = self.currSlideIndex;
						self.currSlideIndex++;

					 } else {

						 DF.canScroll = true;
						 return;

					 }

				 } else {

					 if (self.currSlideIndex > 0) {
						
						self.prevSlideIndex = self.currSlideIndex;
						self.currSlideIndex--;

					 } else {
						 DF.canScroll = true;
						 return;

					 }
				 }

				 self.changeSlideByIndex(self.currSlideIndex, directionNext);

			 }
		 },

		 changeSlideByIndex: function(index, directionNext) {

			 var self = this;

			 DF.canScroll = false;

			 // CALL SLIDES CHANGE 
			 self.prevSlide = self.currSlide;
			 self.currSlide = self.slides.eq(index);


			self.animateSlides(directionNext);

			 if(self.sidenavLinks.length){
				self.sidenavLinks.eq(self.prevSlideIndex).removeClass('is-active');
				self.sidenavLinks.eq(self.currSlideIndex).addClass('is-active');
			 }

		 },

		 noAnimateSlides: function() {

			 var self = this;

			 var elBefore = true;

			 this.slides.each(function(i, el) {
				 if (el == self.currSlide[0]) {
					 elBefore = false;
				 } else {
					 $(el).attr('data-position', elBefore ? 'before' : 'after');
				 }
			 });

			 if (self.prevSlide) self.prevSlide.removeClass('on-stage');

			 setTimeout(function() {
				 self.currSlide.addClass('on-stage');
				 DF.canScroll = true;
			 }, ANIM_TIME);
		 },

		 animateSlides: function(directionNext) {

			 var self = this;

			self.prevSlide.removeClass('is-active on-stage');
			self.currSlide.removeClass('is-active').addClass('on-stage');
			setTimeout(function () {
				DF.canScroll = true;
			}, ANIM_TIME);

			var elBefore = true;

			this.slides.each(function(i, el) {
				 if (el == self.currSlide[0]) {
					 elBefore = false;
				 } else {
					 $(el).attr('data-position', elBefore ? 'before' : 'after');
				 }
			 });

		 },

		 handleSidebarClick: function(cLink) {
			 var self = this;

			 self.sidenavLinks.each(function(i, lnk) {
				 if (lnk === cLink && !$(cLink).hasClass('is-active') && DF.canScroll) {

					self.prevSlideIndex = self.currSlideIndex;
					self.currSlideIndex = i;
					 self.changeSlideByIndex(i, self.prevSlideIndex < i);
					 return;
					 
				 }
			 });
		 },

		 addPagination: function() {
			 var self = this;

			 var $cont = $(self.opts.paginationSelector);

			 if (!$cont.length) {
				 return false;
			 }

			 var el;
			 for (var i = 0; i < self.slideLength; i++) {
				 if (i === 0) {
					 el = $('<li class="slide-link is-active"></li>');
				 } else {
					 el = $('<li class="slide-link"></li>');
				 }

				 $cont.append(el);
			 }

			 self.sidenavLinks = $('.slide-link', $cont);

			 $cont.on('click', '.slide-link', function(e) {
				 e.preventDefault();
				 var cLink = e.target;
				 self.handleSidebarClick(cLink);
			 });

		 },

		 init: function() {

			 var self = this;

			 if (self.slideLength) {

				 DF.canScroll = true;

				 self.currSlideIndex = self.currLink = 0;
				 self.prevSlideIndex = undefined;

				 self.currSlide = self.slides.eq(self.currSlideIndex).addClass(self.opts.ON_STAGE);

				 self.noAnimateSlides();
				 self.bindListeners();

				 if (this.opts.paginationSelector) {
					 this.addPagination();
				 }

			 }
		 }
	 };

	 new DF.SlidePage()

 })();

              
            
!
999px

Console