Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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

              
                
<div id="wrapper">
<p>
Just a rudimentary animated slider to loop through a set of images like cards, polaroid photos, or whatever you want.
</p>
  <div class="card-wrapper">
    
    <div class="card left-card">
      <div class="card-bg">
        <div class="card-img">
          <img src="https://placekitten.com/814/754" alt="">
        </div>
      </div>
    </div>

    <div class="card right-card">
      <div class="card-bg">
        <div class="card-img">
          <img src="https://placekitten.com/899/624" alt="">
        </div>
      </div>
    </div>    

    <div class="card left-card">
      <div class="card-bg">
        <div class="card-img">
          <img src="https://placekitten.com/820/620" alt="">
        </div>
      </div>
    </div>

    <div class="card right-card">
      <div class="card-bg">
        <div class="card-img">
          <img src="https://placekitten.com/800/640" alt="">
        </div>
      </div>
    </div>

    <div class="card left-card">
      <div class="card-bg">
        <div class="card-img">
          <img src="https://placekitten.com/860/610" alt="">
        </div>
      </div>
    </div>    

    <div class="card right-card">
      <div class="card-bg">
        <div class="card-img">
          <img src="https://placekitten.com/900/730" alt="">
        </div>
      </div>
    </div>
    
    <div class="card left-card">
      <div class="card-bg">
        <div class="card-img">
          <img src="https://placekitten.com/660/870" alt="">
        </div>
      </div>
    </div>

    <div class="card right-card">
      <div class="card-bg">
        <div class="card-img">
          <img src="https://placekitten.com/888/666" alt="">
        </div>
      </div>
    </div>    

    <div class="card right-card">
      <div class="card-bg">
        <div class="card-img">
          <img src="https://placekitten.com/800/600" alt="">
        </div>
      </div>
    </div>    

  </div>


<a class="button polaroid-style" href="javascript:;">Toggle Polaroid borders</a>
  
<a class="button full-pen" href="https://codepen.io/nahuel-vivian/full/LYLEZog" target="_blank">View full pen</a>

</div>
              
            
!

CSS

              
                /* Reset */
*, body, html {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

/* Wrapper and cards styling */

.card-wrapper {
  width: 100%;
  min-width: 800px;
  height: 100%;
  min-height: 700px;
  position: relative;
}

.card {
  width: 50%;
  max-width: 300px;
  position: absolute;
  top: 20%;
  left: 40%;
  display: block;
  transition: transform .5s ease;  
  transform-origin: bottom center;
  cursor: pointer;
}

.card.polaroid {
  border: 10px solid white;
  border-bottom: 60px solid white;
  box-shadow: 0 0 15px 0 rgba(0,0,0,.3);
}

.card.polaroid .card-bg {
  padding-top: 90%;
}

.card-bg {
  padding-top: 130%;
  position: relative;
}

.card-img {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
}

.card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 16px;
}

.polaroid .card-img img {
  border-radius: 0
}

.left-card {
  transform: rotate(-15deg);
}

.right-card {
  transform: rotate(15deg);
}

.card.active {
  transform: rotate(0);
}

/* Cards aniamtion */
.card.animate-leave {
  animation: leave .3s;
  animation-fill-mode: both;
  animation-timing-function: ease-in-out;
}

.card.right-card.animate-back {
  animation: backR .3s;
  animation-fill-mode: both;
  animation-timing-function: ease-in-out;
}
.card.left-card.animate-back {
  animation: backL .3s;
  animation-fill-mode: both;
  animation-timing-function: ease-in-out;
}

@keyframes leave {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-110%);
    transform: translateY(-110%) translateX(-20%);
  }
}

@keyframes backR {
  from {
    transform: translateY(-110%);
    transform: translateY(-110%) translateX(-20%);
  }
  to {
    transform: translateY(0) rotate(15deg);
  }
}
@keyframes backL {
  from {
    transform: translateY(-110%);
    transform: translateY(-110%) translateX(-20%);
  }
  to {
    transform: translateY(0) rotate(-15deg);
  }
}



/* Interface */
body {
  background: rgb(34, 31, 40);
}

p {
  display: block;
  font-family: sans-serif;
  text-size: 16px;
  max-width: 600px;
  margin: auto;
  margin-top: 40px;
  padding: 20px;
  border-radius: 14px;
  transition: all ease .2s;
}
.button {
  display: block;
  height: 40px;
  width: 240px;
  text-align: center;
  font-family: sans-serif;
  line-height: 40px;
  font-size: 16px;
  border-radius: 400px;
  position: fixed;
  right: 20px;
  bottom: 20px;
  text-decoration: none;
  color: #ddd;
}

#wrapper .button:last-child {
  right: auto;
  left: 20px;
}

.button, p {
   box-shadow: 3px 3px 12px 0 rgba(0,0,0,.5),
              -3px -3px 12px 0 rgba(255,255,255,.08);
     color: #ebebeb;
}
.button:hover {
  box-shadow: inset 3px 3px 8px 0 rgba(0,0,0,.5),
              inset -3px -3px 8px 0 rgba(255,255,255,.08);
}
p:hover {
  transform: scale(1.02);
}
              
            
!

JS

              
                
$( document ).ready(function() {
	$('.card-wrapper .card').last().addClass('active');
	$('.card-wrapper .card').last().prev().addClass('next');
  // Autoplay interval 
	var interval = 5000;
	var myInt = setInterval(function () {
								$('.card.active').trigger('click');
				      }, interval);
  // Clickable toggle
	$('.card').on('click', function(){
		clearInterval(myInt);
    // Prevent multiple fast clicks to break the functioning
		$('.card').css({'pointer-events' : 'none'});
		$('.card.active').addClass('animate-leave').removeClass('active');
		$('.card.next').addClass('active').removeClass('next');
		$('.card-wrapper .card').last().prev().prev().addClass('next');
		setTimeout( function(){ 
			$('.card.animate-leave').addClass('animate-back').removeClass('animate-leave');
			$('.card-wrapper').prepend( $('.animate-back') );
		}, 300); // Wait for the animation to end
		setTimeout( function(){ 
			$('.card.animate-back').removeClass('animate-back');
			$('.card').css({'pointer-events' : 'auto'});
			clearInterval(myInt);
			myInt = setInterval(function () {
				$('.card.active').trigger('click');
			}, interval);
		}, 700);
	});

  // Just for fun
	$('.polaroid-style').on('click', function(){
		$('.card').toggleClass('polaroid')
	});

});
              
            
!
999px

Console