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="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>
              
            
!

CSS

              
                @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://www.tcmulder.com/codepen/_fpo/photos/");
    }
    &:nth-child(2){
        background-image: url("https://www.tcmulder.com/codepen/_fpo/photos/");
    }
    &:nth-child(3){
        background-image: url("https://www.tcmulder.com/codepen/_fpo/photos/");
    }
    &:nth-child(4){
        background-image: url("https://www.tcmulder.com/codepen/_fpo/photos/");
    }
}
body {
    background: teal;
    box-sizing: border-box;
}
*, *:before, *:after {
    box-sizing: inherit;
}
.hide {
    position: absolute;
    left: -9999px;
}
              
            
!

JS

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

Console