cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              <div class="slider">
  <!-- slides -->
  <div class="slider__slides">
    <div class="slide s--active">
      <div class="slide__inner">
        <div class="slide__content">
          <h2 class="slide__heading">Clip-Path Revealing Slider</h2>
          <p class="slide__text">Greetings, Traveler!</p>
        </div>
      </div>
    </div>
    <div class="slide">
      <div class="slide__inner">
        <div class="slide__content">
          <h2 class="slide__heading">Simple Animation</h2>
          <p class="slide__text">Clip-path magic!</p>
        </div>
      </div>
    </div>
    <div class="slide">
      <div class="slide__inner">
        <div class="slide__content">
          <h2 class="slide__heading">Very Stylish Effect!</h2>
          <p class="slide__text">It looks cool, isn't it?</p>
        </div>
      </div>
    </div>
    <div class="slide">
      <div class="slide__inner">
        <div class="slide__content">
          <h2 class="slide__heading">Limited browser support</h2>
          <p class="slide__text">Forget about IE/Edge and FF</p>
        </div>
      </div>
    </div>
    <div class="slide s--prev">
      <div class="slide__inner">
        <div class="slide__content">
          <h2 class="slide__heading">Check my other stuff!</h2>
          <p class="slide__text"><a href="https://codepen.io/suez/pens/public/" target="_blank">Other demos</a> and <a href="https://twitter.com/NikolayTalanov" target="_blank">Twitter</a></p>
        </div>
      </div>
    </div>
  </div>
  <!-- slides end -->
  <div class="slider__control">
    <div class="slider__control-line"></div>
    <div class="slider__control-line"></div>
  </div>
  <div class="slider__control slider__control--right m--right">
    <div class="slider__control-line"></div>
    <div class="slider__control-line"></div>
  </div>
</div>
            
          
!
            
              *, *:before, *:after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  overflow: hidden;
  font-family: Helvetica, Arial, sans-serif;
}

$numOfSlides: 5;
$slidingAT: 1.3s;
$controlSize: 60px;

.slider {
  position: relative;
  height: 100vh;

  &__slides {
    z-index: 1;
    position: relative;
    height: 100%;
  }

  &__control {
    z-index: 2;
    position: absolute;
    top: 50%;
    left: 5%;
    width: $controlSize;
    height: $controlSize;
    margin-left: $controlSize/-2;
    margin-top: $controlSize/-2;
    border-radius: 50%;
    background: #fff;
    transition: background-color 0.3s;
    cursor: pointer;

    &--right {
      left: 95%;
    }
    
    &:hover {
      background-color: #2da6ff;
    }

    &-line {
      position: absolute;
      left: 23px;
      top: 50%;
      width: 3px;
      height: 14px;
      transform-origin: 50% 0;
      transform: rotate(-45deg);

      &:nth-child(2) {
        transform: translateY(1px) rotate(-135deg);
      }

      .slider__control--right & {
        left: 37px;
        transform-origin: 1px 0;
        transform: rotate(45deg);

        &:nth-child(2) {
          transform: translateY(1px) rotate(135deg);
        }
      }

      &:after {
        content: "";
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        background-color: #e2e2e2;
        transition: background-color 0.3s;
      }

      .slider__control:hover &:after {
        background-color: #fff;
      }

      .slider__control.a--rotation & {

        &:after {
          animation: arrowLineRotation 0.49s;
        }

        &:nth-child(1):after {
          animation: arrowLineRotationRev 0.49s;
        }
      }
    }
  }
}

@keyframes arrowLineRotation {
  to {
    transform: rotate(180deg);
  }
}

@keyframes arrowLineRotationRev {
  to {
    transform: rotate(-180deg);
  }
}

.slide {
  overflow: hidden;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 150vmax;
  height: 150vmax;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  transition: clip-path 0s $slidingAT*0.7;
  clip-path: circle($controlSize/2 at 120vw 50%);

  &.s--prev {
    clip-path: circle($controlSize/2 at 30vw 50%);
  }

  &.s--active {
    z-index: 1;
    transition: clip-path $slidingAT;
    clip-path: circle(120vmax at 120vw 50%);
    
    &.s--active-prev {
      clip-path: circle(120vmax at 30vw 50%);
    }
  }

  @for $i from 1 through $numOfSlides {
    &:nth-child(#{$i}) {
      .slide__inner {
        background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/142996/onepgscr-#{$i+1}.jpg');
      }
    }
  }

  &__inner {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 100vw;
    height: 100vh;
    margin-left: -50vw;
    margin-top: -50vh;
    background-size: cover;
    background-position: center center;

    &:before {
      content: "";
      position: absolute;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      background: rgba(0,0,0,0.3);
    }
  }

  &__content {
    position: absolute;
    left: 5%;
    top: 50%;
    margin-left: $controlSize/-2;
    margin-top: $controlSize*0.8;
    max-width: 480px;
    color: #fff;
  }

  &__heading {
    margin-bottom: 20px;
    font-size: 60px;
  }

  &__text {
    font-size: 25px;

    a {
      color: inherit;
    }
  }
}
            
          
!
            
              (function() {
  var $slides = document.querySelectorAll('.slide');
  var $controls = document.querySelectorAll('.slider__control');
  var numOfSlides = $slides.length;
  var slidingAT = 1300; // sync this with scss variable
  var slidingBlocked = false;

  [].slice.call($slides).forEach(function($el, index) {
    var i = index + 1;
    $el.classList.add('slide-' + i);
    $el.dataset.slide = i;
  });

  [].slice.call($controls).forEach(function($el) {
    $el.addEventListener('click', controlClickHandler);
  });

  function controlClickHandler() {
    if (slidingBlocked) return;
    slidingBlocked = true;

    var $control = this;
    var isRight = $control.classList.contains('m--right');
    var $curActive = document.querySelector('.slide.s--active');
    var index = +$curActive.dataset.slide;
    (isRight) ? index++ : index--;
    if (index < 1) index = numOfSlides;
    if (index > numOfSlides) index = 1;
    var $newActive = document.querySelector('.slide-' + index);

    $control.classList.add('a--rotation');
    $curActive.classList.remove('s--active', 's--active-prev');
    document.querySelector('.slide.s--prev').classList.remove('s--prev');
    
    $newActive.classList.add('s--active');
    if (!isRight) $newActive.classList.add('s--active-prev');
    

    var prevIndex = index - 1;
    if (prevIndex < 1) prevIndex = numOfSlides;

    document.querySelector('.slide-' + prevIndex).classList.add('s--prev');

    setTimeout(function() {
      $control.classList.remove('a--rotation');
      slidingBlocked = false;
    }, slidingAT*0.75);
  };
}());
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console