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

              
                .p_slider
  .p_slider__item
    %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/iwatch1.png'}
  .p_slider__item
    %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/iwatch2.png'}
  .p_slider__item
    %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/iwatch3.png'}
.controls
  .left
    %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/arrow.png'}
  .right
    %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/arrow.png'}
              
            
!

CSS

              
                body{
  margin:0;
  padding:0;
  height:100vh;
  /* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#ffffff+0,ffffff+50,f4f4f4+51,d8d8d8+100 */
background: rgb(255,255,255); /* Old browsers */
background: -moz-linear-gradient(top,  rgba(255,255,255,1) 0%, rgba(255,255,255,1) 50%, rgba(244,244,244,1) 51%, rgba(216,216,216,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,1)), color-stop(50%,rgba(255,255,255,1)), color-stop(51%,rgba(244,244,244,1)), color-stop(100%,rgba(216,216,216,1)));

}
.p_slider{
  width:200px;
  height:339px;
  position:absolute;
  left:0;
  right:0;
  bottom:0;
  top:0;
  margin:auto;
  .left,.right{
    cursor:pointer;
    position:absolute;
    z-index:10;
  }
  &__item{
    position:absolute;
    width:200px;
    height:200px;
    cursor:pointer;
    transition-duration:1.5s;
    transition-property:transform,left,opacity,-webkit-filter;
    //transition-timing-function: cubic-bezier(0, 0.32, 0.26, 0.97);
    img{
      width:200px;
      transform:scale(0);
      position:relative;
      //transition:top 1s;
      animation:scale_bounce 1.2s .4s forwards;
      -webkit-box-reflect: below 4px -webkit-gradient(linear, left top, left bottom, from(transparent), color-stop(50%, transparent), to(rgba(255,255,255,0.2)));
    }
  }
  &__item:nth-of-type(1){
    transform:scale(0.6);
    left:-200px;
    -webkit-filter:blur(2px);
    opacity:0.8;
    z-index:1;
  }
  &__item:nth-of-type(2){
    transform:scale(1);
    left:0px;
    z-index:2;
  }
  &__item:nth-of-type(3){
    transform:scale(0.6);
    left:200px;
    z-index:1;
    -webkit-filter:blur(2px);
    opacity:0.8;
  }

}
.controls{
  position:absolute;
  width:100%;
  top:50%;
  transform:translateY(-50%);
  .left{
    float:left;
    cursor:pointer;
    position:relative;
    left:40px;
    img{
      transform:rotate(180deg);
      transition:all .4s;
      
      opacity:0.2;
      &:hover{
        opacity:1;
        cursor:pointer;
      }
    }
  }
  .right{
    float:right;
    cursor:pointer;
    position:relative;
    right:40px;
    img{
      transition:all .4s;
      opacity:0.2;
      &:hover{
        opacity:1;
        cursor:pointer;
      }
    }
  }
}

@keyframes scale_bounce{
  0%{transform:scale(0)}
  20%{transform:scale(1.1)}
  40%{transform:scale(0.98)}
  60%{transform:scale(1.012)}
  80%{transform:scale(0.995)}
  100%{transform:scale(1)}
}
              
            
!

JS

              
                // 3D Slider for Reece

/*=================================================
INIT
===================================================*/

on = 0;  // Init
time = 500; // Set the delay before the next click is accepted to 1 second
pos = 1; // Set init position
pos2 = 2;
pos3 = 3;

/*=================================================
CLICK FUNCTIONS
===================================================*/

// Right
$('.right').click(function(){
  rotateRight(); // Call
  on = 1; // Set delay on
});

// Left
$('.left').click(function(){
  rotateLeft(); // Call
  on = 1; // Set delay on
});

/*=================================================
AUTOPLAY
===================================================*/

play = setInterval(function(){
  rotateLeft()
},3000)

/*=================================================
ROTATE FUNCTIONS
===================================================*/

// Rotate left
function rotateLeft(){
  if(on == 0){
    $('.p_slider__item:nth-of-type(' + pos + ')').animate({'left':'200px'},200)
    $('.p_slider__item:nth-of-type(' + pos + ')').css('z-index','0')
    $('.p_slider__item:nth-of-type(' + pos2 + ')').animate({'left':'-200px'},200)
    setTimeout (function(){
      $('.p_slider__item:nth-of-type(' + pos2 + ')').css({'transform':'scale(0.6)','opacity':'0.8','webkit-filter':'blur(2px)','z-index':'1'});
      pos++;pos2++;pos3++;
      if(pos > 3){pos = 1}if(pos2 > 3){pos2 = 1;}if(pos3 > 3){pos3 = 1;}
    },400)
    $('.p_slider__item:nth-of-type(' + pos3 + ')').animate({'left':'0px'},200)
    $('.p_slider__item:nth-of-type(' + pos3 + ')').css({'transform':'scale(1)','opacity':'1','webkit-filter':'blur(0px)','z-index':'2'})
    setTimeout (function(){
      on = 0; // Accept clicks again
    },time)
  }
}

// Rotate right
function rotateRight(){
  if(on == 0){
    $('.p_slider__item:nth-of-type(' + pos3 + ')').animate({'left':'-200px'},200)
    $('.p_slider__item:nth-of-type(' + pos3 + ')').css('z-index','0')
    $('.p_slider__item:nth-of-type(' + pos2 + ')').animate({'left':'200px'},200)
    setTimeout (function(){
      $('.p_slider__item:nth-of-type(' + pos2 + ')').css({'transform':'scale(0.6)','opacity':'0.8','webkit-filter':'blur(2px)','z-index':'0'});
      pos--;pos2--;pos3--;
      if(pos < 1){pos = 3}if(pos2 < 1){pos2 = 3;}if(pos3 < 1){pos3 = 3;}
      console.log(pos,pos2,pos3)
    },400)
    $('.p_slider__item:nth-of-type(' + pos + ')').animate({'left':'0px'},200)
    $('.p_slider__item:nth-of-type(' + pos + ')').css({'transform':'scale(1)','opacity':'1','webkit-filter':'blur(0px)','z-index':'1'})
    setTimeout (function(){
      on = 0; // Accept clicks again
    },time)
  }
}

$('.p_slider__item img').hover(function(){
  clearInterval(play)
})
$('.p_slider__item img').mouseenter(function(){
  $(this).animate({'top':'-14px'},300);
})
$('.p_slider__item img').mouseout(function(){
  $(this).stop(true,false).animate({'top':'0px'},300)
  play = setInterval(function(){
    rotateLeft()
  },3000)
})
              
            
!
999px

Console