Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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 class="wrap">
		<a class="btn prev">
			<i class="btn__icon fas fa-chevron-left"></i>
		</a>
		<div class="slide">
			<ul class="slide__box">
				<li class="slide__each first"></li>
				<li class="slide__each second"></li>
				<li class="slide__each third"></li>
				<li class="slide__each fourth"></li>
				<li class="slide__each fifth"></li>
			</ul>
		</div>
		<a class="btn next">
			<i class="btn__icon fas fa-chevron-right"></i>
		</a>
		<div class="pagination">
			<span class="pagination__dot on"></span>
			<span class="pagination__dot"></span>
			<span class="pagination__dot"></span>
			<span class="pagination__dot"></span>
			<span class="pagination__dot"></span>
		</div>
</div>




<!-- <div class="wrap">
		<a class="btn prev">
			<i class="fas fa-chevron-left"></i>
		</a>
		<div class="frame">
			<ul class="slide_box">
				<li class="slide first"></li>
				<li class="slide second"></li>
				<li class="slide third"></li>
				<li class="slide fourth"></li>
				<li class="slide fifth"></li>
			</ul>
		</div>
		<a class="btn next">
			<i class="fas fa-chevron-right"></i>
		</a>
		<div class="pagination_wrap">
			<span class="on"></span>
			<span></span>
			<span></span>
			<span></span>
			<span></span>
		</div>
</div> -->

              
            
!

CSS

              
                body{
	background-color:#1C3F4B;
}

.wrap{
	width: 600px; 
	position: absolute;
	top: 50%; 
	left: 50%; 
	transform: translate(-50%, -50%); 

	.btn{
		position: absolute;
		top: 50%;
		transform:translateY(-50%);

		&__icon{
			padding:8px;
			color: rgba(255,255,255,0.3);
			font-size:42px;
			cursor:pointer;
			transition: all 0.3s;

			&:hover{
				color: rgba(255,255,255,0.8);
				transform: scale(1.1);
			}
		}
		&.prev{
			left: -50px;
		}
		&.next{
			right: -50px;
		}
	}
}	
.slide{
	width: 600px;
	float: left;
	overflow: hidden; 
	
	&__box{
		position: relative;
	}
	&__each{
		width: 600px;
		height: 400px;
		float: left; 
		
		&.first{
			background: url(https://images.unsplash.com/photo-1559344404-d3d24a7480e4?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1489&q=80);
			background-size: cover;
		}
		&.second{
			background: url(https://images.unsplash.com/photo-1511466431307-d603e868975c?ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80);
			background-size: cover;
		}
		&.third{
			background: url(https://images.unsplash.com/photo-1544071157-f0747ad7571a?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80) ;
			background-size: cover;
		}
		&.fourth{
			background: url(https://images.unsplash.com/photo-1557278388-c35168c20518?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjF9&auto=format&fit=crop&w=1400&q=80) ;
			background-size: cover;
		}
		&.fifth{
			background: url(https://images.unsplash.com/photo-1581906847196-566651cc7738?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80);
			background-size: cover;
		}
	}
}
.pagination{
	width: 120px; 
	position: absolute; 
	bottom: 24px;
	left: 50%;
	transform: translateX(-50%); 
	display: flex; 
	justify-content: space-around;
	
	&__dot{
		display: block; 
		width: 6px; 
		height: 6px; 
		border-radius: 50%; 
		background-color: rgba(255,255,255,0.4);
		transition: transform 0.3s;
		
		&.on{
			transform:scale(1.4);
			margin-top:-1px;
			background-color:transparent;
			border: 1px solid #fff;
		}
	}
}



/* All images from https://unsplash.com */

              
            
!

JS

              
                $(document).ready(function(){
  
	$('.wrap').each(function(){
		
	  	var btn = $('.btn'),
	  			slideBox = $('.slide__box'),
	      	slide = slideBox.find('.slide__each'),
	      	slideWidth = slide.width(),
	      	slideCount = slide.length-1,
					paginationWrap = $('.pagination'),
					dot = paginationWrap.find('.pagination__dot'),
					dotCount = dot.length,
					index = $('.pagination .pagination__dot.on').index(); //initial value = 0


/*==================================================================*/


//stop slide on arrows
		btn.on({
		    mouseenter: stopCarousel,
		    mouseleave: autoCarousel
		}); 

		slideBoxInit(); // initialize of slide_box
		autoCarousel(); //auto slide function
		slideBtn(); // prev, next button function


/*==================================================================*/


// initialize of slide_box 
		function slideBoxInit(){

		//insert last slide(cloned) to very first slide (to look naturally when previous button is clicked)
			cloneSlide = slide.eq(slideCount).clone(); 
				
				//change the value of 'left', then the next slide of inserted one(originally, first one) seems like first one.
		    slideBox.css({'width':slideWidth*(slideCount+1),'left':-slideWidth});
			
			slide.eq(0).before(cloneSlide); 
		  slide.eq(slideCount).remove(); 

		} //clonedBefore END


/*==================================================================*/


//auto slide function
		function autoCarousel(){	
			autoSlide =  setInterval(function(){
					slide = slideBox.find('li'); //load new 'li' list everytime

					pagination(); //pagination will work with slide

					slideBox.animate({'left':-slideWidth*2},800,'easeOutQuart', function(){
						cloneSlide = slide.eq(0).clone(); //copy the first slide

						slide.eq(slideCount).after(cloneSlide); //insert the copied slide(cloned one) after last slide
						slide.eq(0).remove(); //remove first slide

						slideBox.css({'left':-slideWidth}); //change the distance of slideBox.animate to default
					});	
				},3500);
		} // autoCarousel END


/*==================================================================*/


//prev next buttons function
		function slideBtn(){

			btn.on('click',function(){
				if ($(this).hasClass('next')) {
					slideBox.animate({'left':-slideWidth*2},300,'easeInSine', function(){
						slide = slideBox.find('li'),
						cloneSlide = slide.eq(0).clone(); 

						slide.eq(slideCount).after(cloneSlide); 
						slide.eq(0).remove(); 

						slideBox.css({'left':-slideWidth}); 
					});	//same function with autoCarousel

			
			//the dot of pagination works when arrows are clicked
					index = $('.pagination .pagination__dot.on').index(); //index of dot.on (initial value = 0)
				  	index++;

					if (index > dotCount-1 ) {index = 0;} 
						dot.removeClass('on');
						dot.eq(index).addClass('on');
				} else {
					slideBox.animate({'left':0},300,'easeInSine', function(){
						var slide = slideBox.find('li'),
							cloneSlide = slide.eq(slideCount).clone(); 

						slide.eq(0).before(cloneSlide); 
						slide.eq(slideCount).remove(); 

						slideBox.css({'left':-slideWidth}); 
					});	

					index = $('.pagination .pagination__dot.on').index();
					index--;

					if (index < 0 ) {index = dotCount-1;}
						dot.removeClass('on');
						dot.eq(index).addClass('on');
				}
			});
		} // slideBtn END


/*==================================================================*/


//pagination
		function pagination(){
				index++;

			if (index > dotCount-1 ) {index = 0;}
				dot.removeClass('on');
				dot.eq(index).addClass('on');  
		} // pagination END


/*==================================================================*/


//오토슬라이드 멈춤
		function stopCarousel(){
		    clearInterval(autoSlide);
		 }


	});//wrap END
	
});//document END
              
            
!
999px

Console