cssAudio - ActiveCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatspinnerstartv

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.

            
              <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<div class="container">
  <div class="thumb">
   <ul>
     <li><img src="http://placehold.it/50/ff0000"  class='thumb'/></li>
     <li><img src="http://placehold.it/50/00ff00" class='thumb'/></li>
     <li><img src="http://placehold.it/50/0000ff"  class='thumb'/></li>
     <li><img src="http://placehold.it/50/F6378F"  class='thumb'/></li>
     <li><img src="http://placehold.it/50/90EEE1"  class='thumb'/></li>
     <li><img src="http://placehold.it/50/FFDD00"  class='thumb'/></li>
   </ul>
  </div>
  <div class="banner">
   <ul>
     <li><img src="http://placehold.it/300/ff0000" class='img' /></li>
     <li><img src="http://placehold.it/300/00ff00" class='img' /></li>
     <li><img src="http://placehold.it/300/0000ff" class='img'/></li>
     <li><img src="http://placehold.it/300/F6378F"  class='img'/></li>
     <li><img src="http://placehold.it/300/90EEE1"  class='img'/></li>
     <li><img src="http://placehold.it/300/FFDD00"  class='img'/></li>
     <span ><i class="fa fa-arrow-circle-left" aria-hidden="true" onclick='left()'></i></span>
  <span ><i class="fa fa-arrow-circle-right" aria-hidden="true" onclick='right()'></i></span>
   </ul>
  </div>
</div>
            
          
!
            
              .container{
  margin:50px auto;
  text-align:center;
  width:70%;
  background-color:whitesmoke;
}
.thumb{
  display:flex;
  justify-content:center;
  margin-bottom:1em ;
}
.thumb ul{
  display:flex;
  list-style:none;
  margin:0;
  margin-top:1em;
  padding:0;
  box-sizing:border-box;
  height:50px;
  overflow:hidden;
}
.thumb ul li{
  margin-left:5px;
  cursor:pointer;
}
.thumb ul li:first-child{
  margin-left:0;
}
.banner{
  display:flex;
  justify-content:center;
}
.banner ul{
  display:flex;
  list-style:none;
  margin:0;
  padding:0;
  box-sizing:border-box;
  width:300px;
  height:300px;
  overflow:hidden;
  position:relative;
}
.banner ul li img{
  position:absolute;
  left:100%;
  width: 100%;
  height: 100%;
}
.banner ul li img.do-transition {
  transition:left 1s linear 0s;
}
span{
  font-size:2em;
  cursor:pointer;
  color:white;
}
.fa-arrow-circle-left{
  position:absolute;
  top:50%;
}
.fa-arrow-circle-right{
  position:absolute;
  top:50%;
  left:91%;
}
            
          
!
            
              var imgy = document.getElementsByClassName('img'),
    thumbs = document.querySelectorAll('img.thumb'),
    count = 0,
    begin = false,
    timer,
    slideWhait = 5000,
    i;
imgy[count].style.left ='0%';
function slidy(dir){
  timer=setTimeout(function(){
    dir();
  },slideWhait);
}
slidy(left);
function left(){
  if(begin){
    return;
  }
  begin =true;
  clearTimeout(timer);
  var exist =imgy[count];
  if(count<imgy.length-1){
    count++;
  }else{
    count=0;
  }
  var nextImg =imgy[count];
  nextImg.classList.remove("do-transition");
  nextImg.style.left ='100%';
  setTimeout(function () {
    exist.classList.add("do-transition");
    nextImg.classList.add("do-transition");
    exist.style.left='-100%';
    nextImg.style.left ='0%';
    setTimeout(function () {
      exist.classList.remove("do-transition");
      nextImg.classList.remove("do-transition");
      begin = false;
      slidy(left);
    }, 1000);
  }, 0);
}
function right(){
  if(begin){
    return;
  }
  begin =true;
  clearTimeout(timer);
  var exist =imgy[count];
  if(count>0){
    count--;
  }else{
    count=imgy.length-1;
  }
  var lastImg =imgy[count];
  lastImg.classList.remove("do-transition");
  lastImg.style.left ='-100%';
  setTimeout(function(){
    exist.classList.add("do-transition");
    lastImg.classList.add("do-transition");
    exist.style.left='100%';
    lastImg.style.left ='0%';
    setTimeout(function(){
      exist.classList.remove("do-transition");
      lastImg.classList.remove("do-transition");
      begin=false;
      slidy(right);
    },1000);
  },0);
}
for (i = 0; i < thumbs.length; i += 1) {
  (function (thumb, i) {
    thumb.onclick = function () {
      if (begin || count === i) {
        console.log(begin, count, i);
        return;
      }
      begin = true;
      clearTimeout(timer);
      var exist =imgy[count];
      count = i;
      var nextImg =imgy[count];
      nextImg.classList.remove("do-transition");
      nextImg.style.left ='100%';
      setTimeout(function(){
        exist.classList.add("do-transition");
        nextImg.classList.add("do-transition");
        exist.style.left='-100%';
        nextImg.style.left ='0%';
        setTimeout(function(){
          exist.classList.remove("do-transition");
          nextImg.classList.remove("do-transition");
          begin=false;
          slidy(left);
        },1000);
      },0);
      
      
    };
  }(thumbs[i], i));
}
            
          
!
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