css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              .slider-ctr

  figure.slide
    img(src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/111167/img5.jpeg", alt="Sky")
    figcaption 
      .title Sky
      .author Aleksandra
  
  figure.slide
    img(src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/111167/img1.jpeg", alt="River")
    figcaption 
      .title River
      .author Ales Krivec

  figure.slide
    img(src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/111167/img4.jpeg", alt="Rain")
    figcaption
      .title Rain
      .author Wilson Lau
      
  figure.slide.text-on
    img(src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/111167/img2.jpeg", alt="Ocean")
    figcaption
      .title Ocean
      .author Rosan Harmens
      
  .slider-control
    .control.prev.disabled
      .icon.ion-chevron-left
    .control.next
      .icon.ion-chevron-right
            
          
!
            
              @import "bourbon";
@import url(https://fonts.googleapis.com/css?family=Roboto:400,300);

html,
body {
  height: 100%;
  position: relative;
  font-family: Roboto;
  background: #f8f8f8;
}

.slider-ctr {
  width: 700px;
  height: 440px;
  @include position(absolute, 50% x x 50%);
  margin-top: -220px;
  margin-left: -350px;
  box-sizing: border-box;
  border: 10px solid white;
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0 10px 15px 3px rgba(0,0,0,.15), 0 5px 20px 3px rgba(0,0,0,.1);
  
  &:after {
    content: "";
    @include position(absolute, 0 0 0 0);
    background: linear-gradient(to bottom, transparent 70%, rgba(0,0,0,0.6) 100%);
    background: -webkit-linear-gradient(to bottom, transparent 70%, rgba(0,0,0,0.6) 100%);
    pointer-events: none;
    z-index: 9;
  }
}

.slider-control {
  @include position(absolute, x 30px 30px x);
  width: 80px;
  overflow: hidden;
  border-radius: 3px;
  box-shadow: 0 3px 3px 3px rgba(0,0,0,.15);
  z-index: 99;
  
  .control {
    width: 50%;
    height: 40px;
    display: block;
    float: left;
    text-align: center;
    line-height: 40px;
    cursor: pointer;
    transition: .3s all ease;
    background: white;
    
    .icon {
      pointer-events: none;
      transition: .3s all ease;
    }
    
    &.disabled {
      pointer-events: none;
      background: #ddd;
      
      .icon {
        opacity: .5;
      }
    }
  }
}

.slide {
  @include position(absolute, 0 0 0 0);
  transition: .45s all cubic-bezier(0.65, 0.05, 0.36, 1);
  -webkit-clip-path: inset(0 0 0 0);
  clip-path: inset(0 0 0 0);
  
  &:before {
    content: "";
    @include position(absolute, 0 0 0 0);
    background: rgba(0,0,0,.125);
  }
  
  // slide-on animation
  &.slide-on {
    -webkit-clip-path: inset(0 100% 0 0);
    clip-path: inset(0 100% 0 0);
  }
  
  &.text-on .title {
    transition: .3s all cubic-bezier(0.65, 0.05, 0.36, 1) .45s;
    -webkit-clip-path: inset(0 0 0 0);
    clip-path: inset(0 0 0 0);
  }
  
  &.text-on .author {
    transition: .3s all cubic-bezier(0.65, 0.05, 0.36, 1) .6s;
    -webkit-clip-path: inset(0 0 0 0);
    clip-path: inset(0 0 0 0);
  }
  
  img {
    display: block;
  }
  
  figcaption {
    @include position(absolute, 30px x x 30px);
  }
  
  .title {
    font-size: 50px;
    margin-bottom: 2px;
    color: white;
    transition: .3s all cubic-bezier(0.65, 0.05, 0.36, 1) .45s;
    -webkit-clip-path: inset(0 0 0 100%);
    clip-path: inset(0 0 0 100%);
    font-weight: 400;
    letter-spacing: 10px;
    text-transform: uppercase;
    position: relative;
  }
  
  .author {
    font-size: 16px;
    color: white;
    opacity: .8;
    transition: .3s all cubic-bezier(0.65, 0.05, 0.36, 1) .45s;
    -webkit-clip-path: inset(0 0 0 100%);
    clip-path: inset(0 0 0 100%);
    font-weight: 300;
    letter-spacing: 3px;
    position: relative;
    z-index: 9;
  }
}
            
          
!
            
              // buttons
var sliderControl = document.querySelector(".slider-control");

// slides informations
var slides = document.querySelectorAll(".slide"),
    slidesLength = slides.length;

// slides array
var slidesArr = [].slice.call(slides);

// reverse array sorting
slidesArr = slidesArr.reverse();

// slide current
var slideCurrent = 0;

sliderControl.addEventListener("click", function(e){
  target = e.target;
  
  // get next button
  if(target.classList.contains("next")){

    next = e.target,
    prev = next.previousElementSibling,
    nextSlide = slidesArr[slideCurrent + 1],
    slide = slidesArr[slideCurrent];
    
    slide.classList.add("slide-on");
    slide.classList.remove("text-on");
    nextSlide.classList.add("text-on");
    
    slideCurrent += 1;
    
    if(slideCurrent > 0) {
      prev.classList.remove("disabled");
    }
    
    if(slideCurrent === slidesLength - 1){
      next.classList.add("disabled");
    }
  }
  
  // get prev button
  if(target.classList.contains("prev")){
    
    slideCurrent -= 1;
    
    prev = e.target,
    next = prev.nextElementSibling,
    prevSlide = slidesArr[slideCurrent + 1],
    slide = slidesArr[slideCurrent];
    
    prevSlide.classList.remove("text-on");
    slide.classList.remove("slide-on");
    slide.classList.add("text-on");
    
    if(slideCurrent === slidesLength - 2){
      next.classList.remove("disabled");
    }

    if(slideCurrent === 0){
      prev.classList.add("disabled");
    }
    
  }

});

balapaCop("Image Slider", "#999");
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console