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="container __loading">

<ul>
		<li>コーディング中は、あえてファイルサイズが重い画像を使うのがおすすめです。<br>(読み込み時間が長くなってアニメーションの挙動を確認しやすいので)</li>
		<li>ページをリロードする時は、ハード再読み込み(Command+Shift+R)しましょう。<br>(画像のキャッシュが残っていると読み込み時間が短くなってしまうので)</li>
</ul>

<!-- ########################################## -->
<!-- グレーの透明度が点滅するアニメーション -->
<!-- ########################################## -->
<div class="wrap-fade-toggle">

	<div class="card">
		<div class="card__img anima-fade-toggle">
			<img src="https://cdn.spacetelescope.org/archives/images/publicationjpg/heic1901a.jpg" alt="" width="200" height="150">
		</div>
		<div class="card__ttl anima-fade-toggle">heic1901a</div>
	</div>

	<div class="card">
		<div class="card__img anima-fade-toggle">
			<img src="https://cdn.spacetelescope.org/archives/images/publicationjpg/heic1808a.jpg" alt="" width="200" height="150">
		</div>
		<div class="card__ttl anima-fade-toggle">heic1808a</div>
	</div>

	<div class="card">
		<div class="card__img anima-fade-toggle">
			<img src="https://cdn.spacetelescope.org/archives/images/large/heic0821b.jpg" alt="" width="200" height="150">
		</div>
		<div class="card__ttl anima-fade-toggle">heic0821b</div>
	</div>

	<div class="card">
		<div class="card__img anima-fade-toggle">
			<img src="https://cdn.spacetelescope.org/archives/images/large/potw1441a.jpg" alt="" width="200" height="150">
		</div>
		<div class="card__ttl anima-fade-toggle">potw1441a</div>
	</div>

	<div class="card">
		<div class="card__img anima-fade-toggle">
			<img src="https://cdn.spacetelescope.org/archives/images/large/heic0715a.jpg" alt="" width="200" height="150">
		</div>
		<div class="card__ttl anima-fade-toggle">heic0715a</div>
	</div>

	<div class="card">
		<div class="card__img anima-fade-toggle">
			<img src="https://cdn.spacetelescope.org/archives/images/large/potw2114a.jpg" alt="" width="200" height="150">
		</div>
		<div class="card__ttl anima-fade-toggle">potw2114a</div>
	</div>

</div>

<hr>

<!-- ########################################## -->
<!-- グラデーションが移動するアニメーション -->
<!-- ########################################## -->
<div class="wrap-gradient">

	<div class="card">
		<div class="card__img anima-gradient">
			<img src="https://cdn.spacetelescope.org/archives/images/publicationjpg/heic1901a.jpg" alt="" width="200" height="150">
		</div>
		<div class="card__ttl anima-gradient">heic1901a</div>
	</div>

	<div class="card">
		<div class="card__img anima-gradient">
			<img src="https://cdn.spacetelescope.org/archives/images/publicationjpg/heic1808a.jpg" alt="" width="200" height="150">
		</div>
		<div class="card__ttl anima-gradient">heic1808a</div>
	</div>

	<div class="card">
		<div class="card__img anima-gradient">
			<img src="https://cdn.spacetelescope.org/archives/images/large/heic0821b.jpg" alt="" width="200" height="150">
		</div>
		<div class="card__ttl anima-gradient">heic0821b</div>
	</div>

	<div class="card">
		<div class="card__img anima-gradient">
			<img src="https://cdn.spacetelescope.org/archives/images/large/potw1441a.jpg" alt="" width="200" height="150">
		</div>
		<div class="card__ttl anima-gradient">potw1441a</div>
	</div>

	<div class="card">
		<div class="card__img anima-gradient">
			<img src="https://cdn.spacetelescope.org/archives/images/large/heic0715a.jpg" alt="" width="200" height="150">
		</div>
		<div class="card__ttl anima-gradient">heic0715a</div>
	</div>

	<div class="card">
		<div class="card__img anima-gradient">
			<img src="https://cdn.spacetelescope.org/archives/images/large/potw2114a.jpg" alt="" width="200" height="150">
		</div>
		<div class="card__ttl anima-gradient">potw2114a</div>
	</div>

</div>
	
</div>
              
            
!

CSS

              
                /* ############################################## */
/* 共通(アニメーションとは直接関係のないスタイル) */
/* ############################################## */

body{
	padding: 20px;
}

.wrap-fade-toggle,
.wrap-gradient{
	display: flex;
	flex-wrap: wrap;
}

.card{
	width: 200px;
	margin: 4%;
}
.card__img{
	position: relative; /* 両方のアニメーションで必要 */
	overflow: hidden; /* グラデーションが移動するアニメーションで必要 */
}
.card__ttl{
	display: inline-block;
	font-weight: bold;
	margin-top: 8px;
	position: relative; /* 両方のアニメーションで必要 */
	overflow: hidden; /* グラデーションが移動するアニメーションで必要 */
}



/* ############################################## */
/* グレーの透明度が点滅するアニメーション */
/* ############################################## */

/* 重ねるグレーのベース */
.anima-fade-toggle::before {
	content: "";
	background-color: #eee;
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	transition: opacity .4s, visibility .4s;
}

/* 読み込み中 */
.container.__loading .anima-fade-toggle::before {
	animation: anima_fade_toggle 1s infinite;
	animation-direction: alternate;
}
@keyframes anima_fade_toggle {
	0% {
		background-color: #eee;
	}
	100% {
		background-color: #bbb;
	}
}

/* 読み込み完了後 */
.container.__loaded .anima-fade-toggle::before {
	opacity: 0;
	visibility: hidden;
}



/* ############################################## */
/* グラデーションが移動するアニメーション */
/* ############################################## */

/* 重ねるグレーのベース */
.anima-gradient::before {
	content: "";
	background: linear-gradient(90deg, #f1f1f1 0%, #ccc 50%, #f1f1f1 100%);
	position: absolute;
	top: 0;
	left: 0;
	width: 300%;
	height: 100%;
	z-index: 1;
	transition: opacity .4s, visibility .4s;
}
.anima-gradient::after {
	content: "";
	background-color: #f1f1f1;
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	transition: opacity .4s, visibility .4s;
}

/* 読み込み中 */
.container.__loading .anima-gradient::before {
	animation: anima_gradient 2.2s ease-in-out infinite;
	opacity: 0.9;
}
@keyframes anima_gradient {
	0% {
		left: -300%;
	}
	100% {
		left: 300%;
	}
}

/* 読み込み完了後 */
.container.__loaded .anima-gradient::before,
.container.__loaded .anima-gradient::after {
	opacity: 0;
	visibility: hidden;
}

              
            
!

JS

              
                // DOMや画像など全てを読み込み後、.containerのクラスを切替え
window.addEventListener('load', function(_ev) {
	document.querySelector('.container').classList.remove('__loading');
	document.querySelector('.container').classList.add('__loaded');
});
              
            
!
999px

Console