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

              
                <header>
 <div class="banner">
  <div class="img-1" style="background-image: url(https://unsplash.it/1280/640?image=1044);"></div>
  <div class="img-2" style="background-image: url(https://unsplash.it/1280/640?image=1033);"></div>
  <div class="img-3" style="background-image: url(https://unsplash.it/1280/640?image=1019);"></div>
  <div class="img-4" style="background-image: url(https://unsplash.it/1280/640?image=1000);"></div>
 </div>
</header>
<h1>CSS Looping Fader</h1>
<p>This is based on an example by <a href="https://snook.ca/archives/html_and_css/simplest-css-slideshow">Jonathan Snook</a>, but has been updated to fade seamlessly between images without cross fading (which reveals the background). This is achieved by animating the z-index while simultaneously delaying the fade out of each layer until the replacing layer is fully visible.</p>
<p>While the animation timeline does depend on a set number of images, it would be possible to set up classes for each variation (for example, 4, 5, and 6 image rotations). The total duration = (fade curation + visible duration) * number of images. More details can be found in the Jonathan Snook article linked above.</p>
<p>This version also uses CSS backgrounds (defined in the HTML by an assumed CMS) instead of IMG tags to provide a more seamless (and responsive, depending on your CSS setup) end result.</p>

<h1>Other animations</h1>
<p>Among any other animatable CSS effects, clipping path animations are pretty effective. However, this may take significantly more processing power (so watch your CPU!).</p>

<section>
 <div class="banner">
  <div class="img-1" style="background-image: url(https://unsplash.it/1280/640?image=993);"></div>
  <div class="img-2" style="background-image: url(https://unsplash.it/1280/640?image=221);"></div>
  <div class="img-3" style="background-image: url(https://unsplash.it/1280/640?image=984);"></div>
  <div class="img-4" style="background-image: url(https://unsplash.it/1280/640?image=651);"></div>
 </div>
</section>
              
            
!

CSS

              
                html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
	margin: 0;
	padding: 0;
	border: 0;
	outline: 0;
	font-weight: inherit;
	font-style: inherit;
	font-size: 100%;
	font-family: inherit;
	vertical-align: baseline;
}

body {
	line-height: 1;
	font-family: 'Avenir Next', 'Myriad', sans-serif;
	-webkit-font-smoothing: antialiased;
	text-align: center;
}

header, section, footer,
aside, nav, article, figure {
	display: block;
}

body {
	width: 100%;
	color: #767a7d;
	background-color: #1b2126;
}

header {
	width: 100%;
	height: 480px;
	margin: 0 0 40px 0;
	padding: 0;
}

a, a:visited {
	color: #a4a6a8;
	text-decoration: none;
	-webkit-transition: color 0.2s ease;
	-moz-transition: color 0.2s ease;
	-ms-transition: color 0.2s ease;
	-o-transition: color 0.2s ease;
	transition: color 0.2s ease;
}

a:hover, a:active {
	color: #d1d3d4;
	text-decoration: none;
}

a:focus {
	outline: none;
}

a.info, a.info:visited, a.info:hover, a.info:active, a.purchase, a.purchase:visited, a.purchase:hover, a.purchase:active {
	color: #ffffff;
	-webkit-transition: background-color 0.2s ease;
	-moz-transition: background-color 0.2s ease;
	-ms-transition: background-color 0.2s ease;
	-o-transition: background-color 0.2s ease;
	transition: background-color 0.2s ease;
}

a.info:hover, a.info:active, a.purchase:hover, a.purchase:active {
	background-color: #f2b90c;
}

h1, h2, h3, h4, h5, h6 {
	line-height: 1.5em;
	color: #ffffff;
}

h1 {
	font-size: 2em;
}

h2 {
	font-size: 3em;
	font-weight: 100;
}

h3 {
	font-size: 1.5em;
}

h4 {
	font-size: 1.3em;
}

p {
	width: 480px;
	margin: 2em auto;
}

/* Banner Backgrounds
/*---------------------------------------------*/

.banner {
	position: absolute;
	width: 100%;
	height: 480px;
}

.img-1, .img-2, .img-3, .img-4 {
	position: absolute;
	top: 0;
	width: 100%;
	height: 480px;
	background-size: cover;
	background-repeat: no-repeat;
	background-position: center;
	z-index: -18;
	opacity: 0;
	animation-name: fade;
	animation-duration: 16s;
	animation-iteration-count: infinite;
}

section .img-1, section .img-2, section .img-3, section .img-4 {
	opacity: 1;
	animation-name: iris;
	animation-duration: 16s;
	animation-iteration-count: infinite;
}

.img-1 { animation-delay: 0s; }
.img-2 { animation-delay: 4s; }
.img-3 { animation-delay: 8s; }
.img-4 { animation-delay: 12s; }

/* Banner Animations (4s per image, 16s total timeline)
/*---------------------------------------------*/

@keyframes crossfade {
	/* This is the default behaviour as described by Jonathan Snook*/
	00.00%	{ opacity: 0; }
	06.25%	{ opacity: 1; }
	25.00%	{ opacity: 1; }
	31.25%	{ opacity: 0; }
	100.0%	{ opacity: 0; }
}

@keyframes fade {
	/* By offsetting the fade out and animating z-index, we can prevent the background from showing up at all*/
	00.00%	{ opacity: 0; z-index: -10; }
	06.25%	{ opacity: 1; z-index: -10; }
	31.25%	{ opacity: 1; z-index: -12; }
	37.50%	{ opacity: 0; z-index: -14; }
	100.0%	{ opacity: 0; z-index: -16; }
}

/* Animating a clip-path in Google Chrome can destroy performance...it's crazy CPU intensive */
@keyframes iris {
	00.0%	{ clip-path: circle(0% at 50% 0%); z-index: -10; }
	12.5%	{ clip-path: circle(120% at 50% 0%); z-index: -10; }
	31.25%	{ clip-path: circle(120% at 50% 0%); z-index: -12; }
	37.50%	{ clip-path: circle(0% at 50% 0%); z-index: -14; }
	100%	{ clip-path: circle(0% at 50% 0%); z-index: -16; }
}
              
            
!

JS

              
                
              
            
!
999px

Console