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

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

              
                <p>Hover on slider to stop sliding</p>

<!-- slider 1 -->

<div class="simple-slider-wrapper">
	<div class="control_prev"><span></span></div>
	<div class="control_next"><span></span></div>
	<div class="simple-slider-overflow-hidden">
		<ul class="simple-slider">
			<li class="simple-slider-element 1">
				<image class="slide-image"  src="https://images.unsplash.com/photo-1590508292979-a30664cfdb51"  />
			</li>
			<li class="simple-slider-element 2">
				<image class="slide-image"  src="https://images.unsplash.com/photo-1548658166-136d9f6a7e76"  />
			</li>
			<li class="simple-slider-element 3">
				<image class="slide-image"  src="https://images.unsplash.com/photo-1504595403659-9088ce801e29"  />
			</li>
			<li class="simple-slider-element 4">
				<image class="slide-image"  src="https://images.unsplash.com/photo-1562462863-42d40916e6b8"  />
			</li>
			<li class="simple-slider-element 5">
				<image class="slide-image"  src="https://images.unsplash.com/photo-1535930891776-0c2dfb7fda1a"  />
			</li>
			<li class="simple-slider-element 5">
				<image class="slide-image"  src="https://images.unsplash.com/photo-1507146426996-ef05306b995a"  />
			</li>
		</ul>
	</div>
</div>



<!--  slider 2 -->

<div class="simple-slider-wrapper">
	<div class="control_prev"><span></span></div>
	<div class="control_next"><span></span></div>
	<div class="simple-slider-overflow-hidden">
		<ul class="simple-slider">
			<li class="simple-slider-element 1">
				<image class="slide-image"  src="https://images.unsplash.com/photo-1590508292979-a30664cfdb51"  />
			</li>
			<li class="simple-slider-element 2">
				<image class="slide-image"  src="https://images.unsplash.com/photo-1548658166-136d9f6a7e76"  />
			</li>
			<li class="simple-slider-element 3">
				<image class="slide-image"  src="https://images.unsplash.com/photo-1504595403659-9088ce801e29"  />
			</li>
			<li class="simple-slider-element 4">
				<image class="slide-image"  src="https://images.unsplash.com/photo-1562462863-42d40916e6b8"  />
			</li>
			<li class="simple-slider-element 5">
				<image class="slide-image"  src="https://images.unsplash.com/photo-1535930891776-0c2dfb7fda1a"  />
			</li>
			<li class="simple-slider-element 5">
				<image class="slide-image"  src="https://images.unsplash.com/photo-1507146426996-ef05306b995a"  />
			</li>
		</ul>
	</div>
</div>

<!-- slider 3 -->

<div class="simple-slider-wrapper">
	<div class="control_prev"><span></span></div>
	<div class="control_next"><span></span></div>
	<div class="simple-slider-overflow-hidden">
		<ul class="simple-slider">
			<li class="simple-slider-element 1">
				<image class="slide-image"  src="https://images.unsplash.com/photo-1590508292979-a30664cfdb51"  />
			</li>
			<li class="simple-slider-element 2">
				<image class="slide-image"  src="https://images.unsplash.com/photo-1548658166-136d9f6a7e76"  />
			</li>
			<li class="simple-slider-element 3">
				<image class="slide-image"  src="https://images.unsplash.com/photo-1504595403659-9088ce801e29"  />
			</li>
			<li class="simple-slider-element 4">
				<image class="slide-image"  src="https://images.unsplash.com/photo-1562462863-42d40916e6b8"  />
			</li>
			<li class="simple-slider-element 5">
				<image class="slide-image"  src="https://images.unsplash.com/photo-1535930891776-0c2dfb7fda1a"  />
			</li>
			<li class="simple-slider-element 5">
				<image class="slide-image"  src="https://images.unsplash.com/photo-1507146426996-ef05306b995a"  />
			</li>
		</ul>
	</div>
</div>
              
            
!

CSS

              
                html, body {
    background-color: blueviolet;
    margin: 0;
    padding: 0;
}

* {
    box-sizing: border-box;
}

p {
	text-align: center;
	font-size: 20px;
	font-weight: 700;
}

.simple-slider-wrapper {
    width: 100%;
    max-width: 500px;
    height: 300px;
    margin: 0 auto 30px auto;
    position: relative;
}

.control_prev,
.control_next {
    display: none;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 99999;
    width:48px;
    height: 48px;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 38px;
    overflow: hidden;
    cursor: pointer;
}

.control_prev {
    left: 0;
}

.control_next {
    right: 0;
}

.control_prev span:before,
.control_next span:before {
    content: "";
    width: 48px;
    height: 48px;
    position: absolute;
}

.control_prev span:before {
    background: url('https://www.flaticon.com/svg/static/icons/svg/271/271218.svg') no-repeat;
    top: 0;
    right: 0;
}

.control_next span:before {
    background: url('https://www.flaticon.com/svg/static/icons/svg/271/271226.svg') no-repeat;
    top: 0;
    left: 0;
}

.simple-slider-overflow-hidden {
    overflow: hidden;
    width: 100%;
    height: 100%;
		padding: 0 50px;
}

.simple-slider {
    display: flex;
    overflow: hidden;
    position: relative;
    margin: 0;
    padding: 0;
    list-style: none;
    width: 100%;
    height: 100%;
}

.simple-slider-element {
    width: 100%;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.slide-image {
    object-fit: cover;
	height: 150%;
	width: auto
}
              
            
!

JS

              
                jQuery(document).ready(function($) {

    $('.simple-slider-wrapper').each(function() {
        const this_slider = $(this);
        
        const slides = this_slider.find('ul li');
        const control_prev = this_slider.find('.control_prev');
        const control_next = this_slider.find('.control_next');

        function slider_init() {
            if (slides.length > 1) {
                control_prev.css('display', 'block');
                control_next.css("display", "block");
            }
        }
        slider_init();

        function moveRight() {
            // move last child to beginning of list and set list position to -100%
            this_slider.find('ul li:last-child').prependTo(this_slider.find('ul'));
            slides.css('left', '-100%');
            // move all list elements to right
            slides.stop().animate({ left: 0 }, 500);
        };

        function moveLeft() {
            // move all list elements to left
            const arr = [ slides.stop().animate({ left: '-100%' }, 500).promise() ]
            // after animation end move first child to end of list and set list position to 0
            $.when.apply($, arr).then(function() {
                this_slider.find('ul li:first-child').appendTo(this_slider.find('ul'));
                slides.css('left', 0);
            });
        };

        control_prev.click(function () {
            if (slides.length > 1) {
                moveRight();
            }
        });

        control_next.click(function () {
            if (slides.length > 1) {
                moveLeft();
            }
        });

        // autoplay
        function setAutoplay() {
            let is_slider_on = true;
            let autoplay = setInterval(function () {
                if (slides.length > 1) {
                    moveLeft();
                }
            }, 3000);

            this_slider.on('mouseenter', function() {
                clearInterval(autoplay);
                is_slider_on = false;
            });

            this_slider.on('mouseleave', function() {
                if (!is_slider_on) {
                    autoplay = setInterval(function () {
                        moveLeft();
                    }, 3000);
									is_slider_on = true;
                }
            });
        }
        setAutoplay();
    });

});
              
            
!
999px

Console