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

Quick-add: + add another resource

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.

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-container">
  <div class="slider-control left inactive"></div>
  <div class="slider-control right"></div>
  <ul class="slider-pagi"></ul>
  <div class="slider">
    <div class="slide slide-0 active">
      <div class="slide__bg"></div>
      <div class="slide__content">
        <svg class="slide__overlay" viewBox="0 0 720 405" preserveAspectRatio="xMaxYMax slice">
          <path class="slide__overlay-path" d="M0,0 150,0 500,405 0,405" />
        </svg>
        <div class="slide__text">
          <h2 class="slide__text-heading">Project name 1</h2>
          <p class="slide__text-desc">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio veniam minus illo debitis nihil animi facere, doloremque voluptate tempore quia. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio veniam minus illo debitis nihil animi facere, doloremque voluptate tempore quia.</p>
          <a class="slide__text-link">Project link</a>
        </div>
      </div>
    </div>
    <div class="slide slide-1 ">
      <div class="slide__bg"></div>
      <div class="slide__content">
        <svg class="slide__overlay" viewBox="0 0 720 405" preserveAspectRatio="xMaxYMax slice">
          <path class="slide__overlay-path" d="M0,0 150,0 500,405 0,405" />
        </svg>
        <div class="slide__text">
          <h2 class="slide__text-heading">Project name 2</h2>
          <p class="slide__text-desc">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio veniam minus illo debitis nihil animi facere, doloremque voluptate tempore quia. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio veniam minus illo debitis nihil animi facere, doloremque voluptate tempore quia.</p>
          <a class="slide__text-link">Project link</a>
        </div>
      </div>
    </div>
    <div class="slide slide-2">
      <div class="slide__bg"></div>
      <div class="slide__content">
        <svg class="slide__overlay" viewBox="0 0 720 405" preserveAspectRatio="xMaxYMax slice">
          <path class="slide__overlay-path" d="M0,0 150,0 500,405 0,405" />
        </svg>
        <div class="slide__text">
          <h2 class="slide__text-heading">Project name 3</h2>
          <p class="slide__text-desc">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio veniam minus illo debitis nihil animi facere, doloremque voluptate tempore quia. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio veniam minus illo debitis nihil animi facere, doloremque voluptate tempore quia.</p>
          <a class="slide__text-link">Project link</a>
        </div>
      </div>
    </div>
    <div class="slide slide-3">
      <div class="slide__bg"></div>
      <div class="slide__content">
        <svg class="slide__overlay" viewBox="0 0 720 405" preserveAspectRatio="xMaxYMax slice">
          <path class="slide__overlay-path" d="M0,0 150,0 500,405 0,405" />
        </svg>
        <div class="slide__text">
          <h2 class="slide__text-heading">Project name 4</h2>
          <p class="slide__text-desc">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio veniam minus illo debitis nihil animi facere, doloremque voluptate tempore quia. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio veniam minus illo debitis nihil animi facere, doloremque voluptate tempore quia.</p>
          <a class="slide__text-link">Project link</a>
        </div>
      </div>
    </div>
  </div>
</div>

            
          
!
            
              @import "compass/css3";

@font-face {
  src: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/142996/polar.otf');
  font-family: 'Polar';
}
$polar: 'Polar', Helvetica, Arial, sans-serif;
$openSans: 'Open Sans', Helvetica, Arial, sans-serif;
@mixin mediaMaxWidth($w) {
  @media (max-width: $w) {
    @content;
  }
}
*, *:before, *:after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html, body {
  font-size: 62.5%;
  height: 100%;
  overflow: hidden;
}
body {
  background: #000;
}
svg {
  display: block;
  overflow: visible;
}
.slider-container {
  position: relative;
  height: 100%;
  user-select: none;
  cursor: all-scroll;
}
.slider-control {
  z-index: 2;
  position: absolute;
  top: 0;
  width: 12%;
  height: 100%;
  transition: opacity 0.3s;
  will-change: opacity;
  opacity: 0;

  &.inactive:hover {
    cursor: auto;
  }

  &:not(.inactive):hover {
    opacity: 1;
    cursor: pointer;
  }

  &.left {
    left: 0;
    background: linear-gradient(to right, rgba(0,0,0,0.18) 0%, rgba(0,0,0,0) 100%);
  }
  &.right {
    right: 0;
    background: linear-gradient(to right, rgba(0,0,0,0) 0%, rgba(0,0,0,0.18) 100%);
  }
}

.slider-pagi {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 2rem;
  transform: translateX(-50%);
  font-size: 0;
  list-style-type: none;
  
  &__elem {
    position: relative;
    display: inline-block;
    vertical-align: top;
    width: 2rem;
    height: 2rem;
    margin: 0 0.5rem;
    border-radius: 50%;
    border: 2px solid #fff;
    cursor: pointer;
    
    &:before {
      content: "";
      position: absolute;
      left: 50%;
      top: 50%;
      width: 1.2rem;
      height: 1.2rem;
      background: #fff;
      border-radius: 50%;
      transition: transform 0.3s;
      transform: translate(-50%, -50%) scale(0);
    }
    
    &.active:before,
    &:hover:before {
      transform: translate(-50%, -50%) scale(1);
    }
  }
}
.slider {
  z-index: 1;
  position: relative;
  height: 100%;

  &.animating {
    transition: transform 0.5s;
    will-change: transform;

    .slide__bg {
      transition: transform 0.5s;
      will-change: transform;
    }
  }
}
.slide {
  position: absolute;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;

  &.active {

    .slide__overlay,
    .slide__text{
      opacity: 1;
      transform: translateX(0);
    }
  }

  &__bg {
    position: absolute;
    top: 0;
    left: -50%;
    width: 100%;
    height: 100%;
    background-size: cover;
    will-change: transform;
  }
  &:nth-child(1) {
    left: 0;

    .slide__bg {
      left: 0;
      background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/142996/3d-slider-3.jpg');
    }

    .slide__overlay-path {
      fill: rgb(233, 156, 126);
    }

    @include mediaMaxWidth(991px) {
      .slide__text {
        background-color: rgba(233, 156, 126, 0.8);
      } 
    }
  }
  &:nth-child(2) {
    left: 100%;

    .slide__bg {
      left: -50%;
      background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/142996/3d-slider-2.jpg');
    }

    .slide__overlay-path {
      fill: rgb(225, 204, 174);
    }

    @include mediaMaxWidth(991px) {
      .slide__text {
        background-color: rgba(225, 204, 174, 0.8);
      } 
    }
  }
  &:nth-child(3) {
    left: 200%;

    .slide__bg {
      left: -100%;
      background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/142996/3d-slider-1.jpg');
    }

    .slide__overlay-path {
      fill: rgb(173, 197, 205);
    }

    @include mediaMaxWidth(991px) {
      .slide__text {
        background-color: rgba(173, 197, 205, 0.8);
      } 
    }
  }
  &:nth-child(4) {
    left: 300%;

    .slide__bg {
      left: -150%;
      background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/142996/3d-slider-4.jpg');
    }

    .slide__overlay-path {
      fill: rgb(203, 198, 195);
    }

    @include mediaMaxWidth(991px) {
      .slide__text {
        background-color: rgba(203, 198, 195, 0.8);
      } 
    }
  }

  &__content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }

  &__overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 100%;
    min-height: 810px;
    transition: transform 0.5s 0.5s, opacity 0.2s 0.5s;
    will-change: transform, opacity;
    transform: translate3d(-20%, 0, 0);
    opacity: 0;

    @include mediaMaxWidth(991px) {
      display: none;
    }

    path {
      opacity: 0.8;
    }
  }

  &__text {
    position: absolute;
    width: 25%;
    bottom: 15%;
    left: 12%;
    color: #fff;
    transition: transform 0.5s 0.8s, opacity 0.5s 0.8s;
    will-change: transform, opacity;
    transform: translateY(-50%);
    opacity: 0;

    @include mediaMaxWidth(991px) {
      left: 0;
      bottom: 0;
      width: 100%;
      height: 20rem;
      text-align: center;
      transform: translateY(50%);
      transition: transform 0.5s 0.5s, opacity 0.5s 0.5s;
      padding: 0 1rem;
    }

    &-heading {
      font-family: $polar;
      font-size: 5rem;
      margin-bottom: 2rem;
      
      @include mediaMaxWidth(991px) {
        line-height: 20rem;
        font-size: 3.5rem;
      }
    }

    &-desc {
      font-family: $openSans;
      font-size: 1.8rem;
      margin-bottom: 1.5rem;

      @include mediaMaxWidth(991px) {
        display: none;
      }
    }

    &-link {
      z-index: 5;
      display: inline-block;
      position: relative;
      padding: 0.5rem;
      cursor: pointer;
      font-family: $openSans;
      font-size: 2.3rem;
      perspective: 1000px;
      
      @include mediaMaxWidth(991px) {
        display: none;
      }

      &:before {
        z-index: -1;
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: #000;
        transform-origin: 50% 100%;
        transform: rotateX(-85deg);
        transition: transform 0.3s;
        will-change: transform;
      }

      &:hover:before {
        transform: rotateX(0);
      }
    }
  }
}
            
          
!
            
              $(document).ready(function() {
  
  var $slider = $(".slider"),
      $slideBGs = $(".slide__bg"),
      diff = 0,
      curSlide = 0,
      numOfSlides = $(".slide").length-1,
      animating = false,
      animTime = 500,
      autoSlideTimeout,
      autoSlideDelay = 6000,
      $pagination = $(".slider-pagi");
  
  function createBullets() {
    for (var i = 0; i < numOfSlides+1; i++) {
      var $li = $("<li class='slider-pagi__elem'></li>");
      $li.addClass("slider-pagi__elem-"+i).data("page", i);
      if (!i) $li.addClass("active");
      $pagination.append($li);
    }
  };
  
  createBullets();
  
  function manageControls() {
    $(".slider-control").removeClass("inactive");
    if (!curSlide) $(".slider-control.left").addClass("inactive");
    if (curSlide === numOfSlides) $(".slider-control.right").addClass("inactive");
  };
  
  function autoSlide() {
    autoSlideTimeout = setTimeout(function() {
      curSlide++;
      if (curSlide > numOfSlides) curSlide = 0;
      changeSlides();
    }, autoSlideDelay);
  };
  
  autoSlide();
  
  function changeSlides(instant) {
    if (!instant) {
      animating = true;
      manageControls();
      $slider.addClass("animating");
      $slider.css("top");
      $(".slide").removeClass("active");
      $(".slide-"+curSlide).addClass("active");
      setTimeout(function() {
        $slider.removeClass("animating");
        animating = false;
      }, animTime);
    }
    window.clearTimeout(autoSlideTimeout);
    $(".slider-pagi__elem").removeClass("active");
    $(".slider-pagi__elem-"+curSlide).addClass("active");
    $slider.css("transform", "translate3d("+ -curSlide*100 +"%,0,0)");
    $slideBGs.css("transform", "translate3d("+ curSlide*50 +"%,0,0)");
    diff = 0;
    autoSlide();
  }

  function navigateLeft() {
    if (animating) return;
    if (curSlide > 0) curSlide--;
    changeSlides();
  }

  function navigateRight() {
    if (animating) return;
    if (curSlide < numOfSlides) curSlide++;
    changeSlides();
  }

  $(document).on("mousedown touchstart", ".slider", function(e) {
    if (animating) return;
    window.clearTimeout(autoSlideTimeout);
    var startX = e.pageX || e.originalEvent.touches[0].pageX,
        winW = $(window).width();
    diff = 0;
    
    $(document).on("mousemove touchmove", function(e) {
      var x = e.pageX || e.originalEvent.touches[0].pageX;
      diff = (startX - x) / winW * 70;
      if ((!curSlide && diff < 0) || (curSlide === numOfSlides && diff > 0)) diff /= 2;
      $slider.css("transform", "translate3d("+ (-curSlide*100 - diff) +"%,0,0)");
      $slideBGs.css("transform", "translate3d("+ (curSlide*50 + diff/2) +"%,0,0)");
    });
  });
  
  $(document).on("mouseup touchend", function(e) {
    $(document).off("mousemove touchmove");
    if (animating) return;
    if (!diff) {
      changeSlides(true);
      return;
    }
    if (diff > -8 && diff < 8) {
      changeSlides();
      return;
    }
    if (diff <= -8) {
      navigateLeft();
    }
    if (diff >= 8) {
      navigateRight();
    }
  });
  
  $(document).on("click", ".slider-control", function() {
    if ($(this).hasClass("left")) {
      navigateLeft();
    } else {
      navigateRight();
    }
  });
  
  $(document).on("click", ".slider-pagi__elem", function() {
    curSlide = $(this).data("page");
    changeSlides();
  });
  
});
            
          
!
999px
Loading ..................

Console