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.

            
              <!-- title -->
<h1>Slider gsap  <a href="https://plus.google.com/u/2/collection/Ueezx" target="_blank">By Em An</a></h1>
<!-- slider -->
<div class="slider">
  <!-- slide -->
  <ul>
    <li class="active"></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
  </ul>
  <ol>
    <!-- point -->
    <li class="active"><i class="fa fa-circle-o"></i></li>
    <li><i class="fa fa-circle-o"></i></li>
    <li><i class="fa fa-circle-o"></i></li>
    <li><i class="fa fa-circle-o"></i></li>
    <li><i class="fa fa-circle-o"></i></li>
    <!-- playpause -->
    <i class="fa playpause fa-pause-circle-o" title="pause"></i>
  </ol>
  <!-- controll -->
  <span class="controll active"></span>
  <span class="controll"></span>
</div>
            
          
!
            
              * {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  -o-box-sizing: border-box;
  box-sizing: border-box;
  padding: 0;
  margin: 0;
  list-style: none;
  font-family: 'Gudea', sans-serif;
  font-weight: normal
}
body {
  background: #eee
}
h1 {
  text-align: center;
  margin-top: 40px;
  font-size: 60px;
  color: #333
}
h1 a {
  font-size: 14px;
  color: #aaa;
  background: #fff;
  border-radius: 5px;
  padding: 2px 5px;
  border: 1px solid #dcdcdc;
  text-decoration: none
}
h1 a:hover {
  color: #0fe0ba;
  text-decoration: underline
}
.slider {
  width: 100%;
  max-width: 750px;
  padding: 0 50px;
  margin: 25px auto 0;
  height: 350px;
  position: relative;
}
.slider ul, .slider ul li {
  width: 100%;
  height: 100%
}
.slider ul {
  position: relative;
  overflow: hidden;
  border-radius: 15px
}
.slider ul li {
  position: absolute;
  top: 0;
  left: -100%;
  background-size: cover; /* semon #f98686 */
  background-position: center;
  color: #fff;
  font-family: serif;
}
.slider ul li:first-of-type {
  background-image: url("http://www.misr5.news/wp-content/uploads/2015/10/6957804-girl-children-blonde-blue-eyes-autumn-mood.jpg")
}
.slider ul li:nth-of-type(2) {
  background-image: url("http://favim.com/orig/201107/19/cute-flowers-girl-pink-pretty-Favim.com-110225.jpg")
}
.slider ul li:nth-of-type(3) {
  background-image: url("http://www.tsitut.net/wp-content/uploads/2016/04/born-to-stand-out.jpg")
}
.slider ul li:nth-of-type(4) {
  background-image: url("https://37.media.tumblr.com/tumblr_lxkb5dtDuF1r5o9ano1_500.jpg")
}
.slider ul li:last-of-type {
  background-image: url("https://s-media-cache-ak0.pinimg.com/originals/03/08/5f/03085f3adecf31a0ded89aec58e5bbed.jpg")
}
.slider .controll {
  width: 40px;
  height: 40px;
  position: absolute;
  top: 44%;
  border-bottom: 3px solid #333;
  border-left: 3px solid #333;
  cursor: pointer;
  color: #333
}
.slider .controll:first-of-type {
  transform: rotate(45deg);
  left: 20px
}
.slider .controll:last-of-type {
  transform: rotate(225deg);
  right: 20px
}
.slider .controll:hover, .slider .controll.active {
  border-color: #f98686 /* rose */
}
.slider ol {
  text-align: center;
  padding-top: 10px
}
.slider ol li {
  display: inline-block;
  margin-right: 5px;
}
.slider ol .fa {
  font-size: 20px;
  color: #333;
  cursor: pointer;
  font-weight: normall
}
.slider ol li:hover .fa:before, .slider ol li.active .fa:before {
  content: "\f111"
}
/* .slider ul li.active {
  z-index: 999;
  left: 0
} */
@media(max-width: 490px) {
  h1 {font-size: 45px}
}
@media(max-width: 350px) {
  h1 {font-size: 25px}
}
            
          
!
            
              $(function() {
    "use strict";
    var body = $("body"),
        active = $(".slider ol li, .slider .controll"),
        controll = $(".slider .controll"),
        playpause = $(".playpause"),
        sliderTime = 1,
        sliderWait = 3000,
        i = 999,
        autoRun,
        stop = false;
    // Reset
    $(".slider ul li:first").css("left", 0);
    // Run Slider
    function runSlider(what) {
        what.addClass("active").siblings("li, span").removeClass("active");
    }
    // slider gsap
    function gsapSlider(whose, left) {
        i++;
        if (whose.hasClass("active")) {
            TweenMax.fromTo(
                ".slider ul li.active",
                sliderTime,
                { zIndex: i, left: left },
                { left: 0 }
            );
        }
    }
    // Active
    active.on("click", function() {
        runSlider($(this));
    });
    // Arrow left
    controll.first().on("click", function() {
        var slide = $(".slider ul li.active, .slider ol li.active").is(
            ":first-of-type"
        )
            ? $(".slider ul li:last, .slider ol li:last")
            : $(".slider ul li.active, .slider ol li.active").prev("li");
        runSlider(slide);
        gsapSlider(slide, "100%");
    });
    // Arrow right
    controll.last().on("click", function() {
        var slide = $(".slider ul li.active, .slider ol li.active").is(
            ":last-of-type"
        )
            ? $(".slider ul li:first, .slider ol li:first")
            : $(".slider ul li.active, .slider ol li.active").next("li");
        runSlider(slide);
        gsapSlider(slide, "-100%");
    });
    // Point
    $(".slider ol li").on("click", function() {
        var start = $(".slider ul li.active").index();
        var slide = $(".slider ul li").eq($(this).index());
        runSlider(slide);
        var end = $(".slider ul li.active").index();
        if (start > end) {
            gsapSlider(slide, "100%");
        }
        if (start < end) {
            gsapSlider(slide, "-100%");
        }
    });
    // Auto run slider
    function autoRunSlider() {
        if (body.css("direction") === "ltr" && stop === false) {
            autoRun = setInterval(function() {
                controll.last().click();
            }, sliderWait);
        } else if (body.css("direction") === "rtl" && stop === false) {
            autoRun = setInterval(function() {
                controll.first().click();
            }, sliderWait);
        }
    }
    autoRunSlider();
    // When hover
    active.on("mouseenter", function() {
        if (stop === false) {clearInterval(autoRun);}
    });
    active.on("mouseleave", function() {
        if (stop === false) {autoRunSlider();}
    });
    // play pause click
    playpause.on("click", function() {
        $(this).toggleClass("fa-play-circle-o fa-pause-circle-o");
        if (playpause.hasClass("fa-play-circle-o")) {
            stop = true;
            clearInterval(autoRun);
            $(this).attr('title', 'play');
        }
        if (playpause.hasClass("fa-pause-circle-o")) {
            stop = false;
            autoRunSlider();
            $(this).attr('title', 'pause');
        }
    });
});

            
          
!
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