Pen Settings

HTML

CSS

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.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

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

              
                <div id="slider">
  <ul id="slider-main">
    <li class="list01"></li>
    <li class="list02"></li>
    <li class="list03"></li>
    <li class="list04"></li>
    <li class="list05"></li>
  </ul>
  <ul id="slider-nav">
    <li><span><</span></li>
    <li><span>></span></li>
  </ul>
  <ul id="slider-thumb">
    <li class="active-thumb"></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
  </ul>
</div>
              
            
!

CSS

              
                *{
    box-sizing: border-box;
}
ul{
    list-style: none;
    padding: 0;
}
#slider {
    width: 90%;
    overflow: hidden;
    position: relative;
    margin: 10px auto;
}
#slider-main {
    height: 500px;
    overflow: hidden;
    margin-bottom:20px;
}
#slider-main li{
    float: left;
    height: 100%;
}
#slider-main li.active-slide{
}

#slider-thumb {
    width: 100%;
    height: 100px;
    overflow: hidden;
    position: relative;
}
#slider-thumb li{
    float: left;
    width: 20%;
    height: 100%;
    overflow: hidden;
    opacity: 1;
    position: relative;
    cursor: pointer;
}
#slider-thumb li:before{
    content: "";
    width: 100%;
    height: 5px;
    position: absolute;
    bottom: 0;
    left: 0;
    transition: 0.3s;
}
#slider-thumb li.active-thumb:before{
    background-color: rgba(0,0,0,0.2);
}

#slider-nav {
    position: absolute;
    overflow: hidden;
    top: 0;
    height: 500px;
    width: 100%;
}
#slider-nav li{
    position: absolute;
    background-color: rgba(255,255,255,1);
    width: 3em;
    padding: 0 1em;
    height: 100%;
    opacity: 0;
    transition: 0.3s;
}
#slider-nav li span{
    top: calc( 50% - 0.5em);
    position: absolute;
}
#slider-nav li:nth-child(2){
   right: 0;
}
#slider-nav li:hover{
  opacity: 0.5;
  cursor: pointer;
}

#slider-main li.list01,
#slider-thumb li:nth-child(1){
  background-color:#e4d2d8;
}
#slider-main li.list02,
#slider-thumb li:nth-child(2){
  background-color:#ddd1e3;
}
#slider-main li.list03,
#slider-thumb li:nth-child(3){
  background-color:#d1d7e3;
}
#slider-main li.list04,
#slider-thumb li:nth-child(4){
  background-color:#d1e3dd;
}
#slider-main li.list05,
#slider-thumb li:nth-child(5){
  background-color:#e3e3d1;
}
              
            
!

JS

              
                $(function(){
    
    var sliderWrap = $('#slider');
    var sliderListWrap = $('#slider-main');
    var sliderList = $('#slider-main li');
    var sliderThumb = $('#slider-thumb li');
    var sliderThumbWrap = $('#slider-thumb');
    var sliderThumbAct;
    var sliderNav = $('#slider-nav li');
    var sliderListAct;   
    var ActiveNum;
    var thumbClickNum;
    var nowplaying = false;
    var TimerID;
    
    var sliderMargin = $(sliderWrap).width();    
    var sliderW = (sliderMargin * sliderList.length);
  
    $(sliderList).css('width', sliderMargin + 'px');
    $(sliderListWrap).css('height', (sliderMargin / 2) + 'px' );
    $(sliderNav).css('height', (sliderMargin / 2) + 'px' );
  
    var sliderTW = $(sliderThumb).width();
    $(sliderThumbWrap).css('height', (sliderTW / 2) + 'px' );

    $(sliderListWrap).css({width:sliderW + 'px', marginLeft:(- sliderMargin) + 'px'})
    $(sliderList).eq(0).addClass('active-slide');
    $(sliderThumb).eq(0).addClass('active-thumb');
    $(sliderList).last().prependTo(sliderListWrap);    
 
  	timerID = setInterval(function(){
		$(sliderNav).eq(1).click();
	},5000);

  
$(window).on('load resize', function(){
setTimeout(function() {
                location.href = location.href; //リロード
            }, 200);
});
  
  //サムネイルクリック  
    $(sliderThumb).click(function(){
        if(nowplaying) return;
        nowplaying = true;

        thumbClickNum = $(sliderThumb).index(this);
        sliderListAct = $('#slider-main li.active-slide'); 
        ActiveNum = $(sliderList).index(sliderListAct); 
        var SA =  ActiveNum - thumbClickNum;
       
        if( SA < 0){//アクティブ<クリック
            $(sliderListWrap).animate({
            marginLeft:(- (Math.abs(SA) + 1) * sliderMargin) + 'px'},1000,function(){
                if(ActiveNum == 0){//active 0の時
                    $(sliderList).eq(sliderList.length - 1).appendTo(sliderListWrap); 
                    for (var i=0; i<Math.abs(SA)-1 ; i++) {  
                        $(sliderList).eq(ActiveNum + i ).appendTo(sliderListWrap);
                    } 
                }else{//active 0以外の時
                    for (var i=0; i<Math.abs(SA); i++) { 
                        $(sliderList).eq(ActiveNum + i -1 ).appendTo(sliderListWrap); 
                    } 
                };
                //marginリセット
                $(sliderListWrap).css('margin-left', (- sliderMargin) + 'px');  
                nowplaying = false;
            });
        
        }else if( SA > 0 ){//クリック<アクティブ
            $(sliderListWrap).animate({
            marginLeft:( (Math.abs(SA)-1) * sliderMargin) + 'px'},1000,function(){
                if(ActiveNum == 1){//active 1の時
                    $(sliderList).eq(sliderList.length - 1).prependTo(sliderListWrap); 
                }else{//active 1以外の時
                    for (var i=0; i<Math.abs(SA); i++) { 
                        $(sliderList).eq(ActiveNum -2 - i ).prependTo(sliderListWrap);  
                    console.log(ActiveNum -2 - i); 
                    } 
                };
                //marginリセット
                $(sliderListWrap).css('margin-left', (- sliderMargin) + 'px');  
                nowplaying = false;
            });
        }else{
            nowplaying = false;  
        }
        
        //active移動
        $(sliderListAct).removeClass('active-slide');         
        $('#slider-thumb li.active-thumb').removeClass('active-thumb');
        $(sliderList).eq(thumbClickNum).addClass('active-slide'); 
        $(sliderThumb).eq(thumbClickNum).addClass('active-thumb');      
    });

    //next click
    $(sliderNav).eq(1).click(function(){
        if(nowplaying) return;
        nowplaying = true;
        slideAnime();
        
        //active移動
        if(ActiveNum == sliderList.length - 1 ){
            $(sliderList).eq(0).addClass('active-slide'); 
            $(sliderThumb).eq(0).addClass('active-thumb');
        }else{
            $(sliderList).eq(ActiveNum + 1).addClass('active-slide'); 
            $(sliderThumb).eq(ActiveNum + 1).addClass('active-thumb');
        }  
        
        $(sliderListWrap).animate({
            marginLeft:(- 2 * sliderMargin) + 'px'},500,function(){                 
        //sliderList最初から最後に移動
        if(ActiveNum == 0){
            $(sliderList).eq(sliderList.length - 1).appendTo(sliderListWrap);
        }else{
            $(sliderList).eq(ActiveNum - 1 ).appendTo(sliderListWrap); 
        }
        //marginリセット
        $(sliderListWrap).css('margin-left', (- sliderMargin) + 'px');  
            nowplaying = false;
        });
     });
    
    //prev click
    $(sliderNav).eq(0).click(function(){
        if(nowplaying) return;
        nowplaying = true;
        slideAnime();
       //active移動        
        if(ActiveNum == 0 ){
             $(sliderList).eq(sliderList.length - 1).addClass('active-slide');
             $(sliderThumb).eq(sliderList.length - 1).addClass('active-thumb');
        }else{
            $(sliderList).eq(ActiveNum - 1).addClass('active-slide');
            $(sliderThumb).eq(ActiveNum - 1).addClass('active-thumb');
            }           
        $(sliderListWrap).animate({
            marginLeft: 0 + 'px' },500,function(){        
           //sliderList最初から最後に移動
            if(ActiveNum == 1){
                $(sliderList).eq(sliderList.length - 1).prependTo(sliderListWrap);     
            }else{
                $(sliderList).eq(ActiveNum - 2 ).prependTo(sliderListWrap);          
            }
            //marginリセット
            $(sliderListWrap).css('margin-left', (- sliderMargin) + 'px');  
            nowplaying = false;
        });
    });
  
    var slideAnime = function(){
        sliderListAct = $('#slider-main li.active-slide'); 
        ActiveNum = $(sliderList).index(sliderListAct);        
        $(sliderListAct).removeClass('active-slide');         
        $('#slider-thumb li.active-thumb').removeClass('active-thumb');        
    };
});  


              
            
!
999px

Console