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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

            
              <div class="cover-slider__wrap">
    <div class="cover-slider__inner">
            I'm essentially trying to create
    a rotating slider wipe effect
    using background-size:cover and background-position:center.
    </div>
    <ul class="cover-slider">
        <li class="cover-slider__slide">
            <span class="hide">Alt Tag</span>
        </li>
        <li class="cover-slider__slide">
            <span class="hide">Alt Tag</span>
        </li>
        <li class="cover-slider__slide">
            <span class="hide">Alt Tag</span>
        </li>
        <li class="cover-slider__slide">
            <span class="hide">Alt Tag</span>
        </li>
    </ul>
</div>
            
          
!
            
              @import "compass/css3";

.cover-slider__wrap {
    position: relative;
    max-width: 640px;
    height: 480px;
    margin: 2em auto;
    padding: 5em 1em;
    color: #fff;
    line-height: 2;
    font-family: 'Trebuchet MS', sans-serif;
    font-weight: bold;
    box-shadow: 0 0 .5em rgba(#000,.5);
}
.cover-slider__inner {
    position: relative;
    min-height: 40em;
    text-align: center;
    z-index: 10;
}
.cover-slider {
    backface-visibility: hidden;
}
.cover-slider__slide {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 100%;
    padding: 0;
    margin: 0;
    background-size: cover;
    background-position: center;
    list-style: none;
    z-index: 0;
    opacity: .5;
    &.active {
        animation-duration: 2500ms;
        animation-name: slidein;
        animation-fill-mode: forwards;
    }
    &.inactive {
        animation-duration: 2500ms;
        animation-name: slideout;
        animation-fill-mode: forwards;
    }
    @keyframes slidein {
        from {
            left: 0;
            right: 100%;
        }
        to {
            left: 0;
            right: 0;
        }
    }
    @keyframes slideout {
        from {
            left: 0;
            right: 0;
        }
        to {
            left: 100%;
            right: 0;
        }
    }
}
// EXTRA STUFF
// these will unfortunately be inline
// in the final product
.cover-slider__slide {
    &:nth-child(1){
        background-image: url("https://unsplash.it/640/480");
    }
    &:nth-child(2){
        background-image: url("https://unsplash.it/641/480");
    }
    &:nth-child(3){
        background-image: url("https://unsplash.it/641/481");
    }
    &:nth-child(4){
        background-image: url("https://unsplash.it/643/482");
    }
}
body {
    background: teal;
    box-sizing: border-box;
}
*, *:before, *:after {
    box-sizing: inherit;
}
.hide {
    position: absolute;
    left: -9999px;
}
            
          
!
            
              // when the dom is ready
jQuery(function($){
	// grab each slider (multiple supported)    
	$('.cover-slider').each(function(){
		// find the slides in this slider
       	var $slides = $(this).find('.cover-slider__slide');
		// get the 0 based amount of slides
        var numSlides = $slides.length - 1;
		// incrementor
        var i = 0;
       
        // rotate slides
       	var rotate = function(){
            // remove all sliding classes
            $slides.removeClass('active inactive');
            // add inactive to the current slide
            $slides.eq(i).addClass('inactive');
            // reset counter if last slide (so animates first one)
            if(i == numSlides){
                i = -1;
            }
            // add active to incremented slide (next slide)
            $slides.eq(++i).addClass('active');
            // call this every few seconds
           	var timer = window.setTimeout(rotate, 5000);
       	};
        // initialize the slider
       	rotate();
	});
});

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console