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

Auto Save

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

              
                .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
              
            
!

CSS

              
                @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;
  }
}
              
            
!

JS

              
                // 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

Console