CSSだけで3Dなカルーセル

0

Result


数年前に見かけた懐かしい感じの3Dなカルーセルです。
CSSだけで出来る時代になりましたね。

css

#slideshow {/*全体*/
	margin: 0 auto;
	padding-top: 50px;
	height: 600px;
	width: 100%;
	background-color: #ddd;
	box-sizing: border-box;
}

.entire-content {/*カルーセルの見栄え。perspectiveで奥行きを設定する*/
	margin: auto;
	width: 190px;
	perspective: 1000px;
	position: relative;
	padding-top: 80px;
}

.content-carrousel {/*各画像を包括、アニメーションを設定*/
	width: 100%;
	position: absolute;
	float: right;
	animation: rotar 15s infinite linear;
	transform-style: preserve-3d;
}

.content-carrousel:hover {/*ホバーしたらアニメーションを停止してポインター表示*/
	animation-play-state: paused;
	cursor: pointer;
}

.content-carrousel figure {/*各画像設定*/
	width: 100%;
	height: 120px;
	border: 1px solid #3b444b;
	overflow: hidden;
	position: absolute;
}

/*個々の画像設定*/
.content-carrousel figure:nth-child(1) {
	transform: rotateY(0deg) translateZ(300px);
}
.content-carrousel figure:nth-child(2) {
	transform: rotateY(40deg) translateZ(300px);
}
.content-carrousel figure:nth-child(3) {
	transform: rotateY(80deg) translateZ(300px);
}
.content-carrousel figure:nth-child(4) {
	transform: rotateY(120deg) translateZ(300px);
}
.content-carrousel figure:nth-child(5) {
	transform: rotateY(160deg) translateZ(300px);
}
.content-carrousel figure:nth-child(6) {
	transform: rotateY(200deg) translateZ(300px);
}
.content-carrousel figure:nth-child(7) {
	transform: rotateY(240deg) translateZ(300px);
}
.content-carrousel figure:nth-child(8) {
	transform: rotateY(280deg) translateZ(300px);
}
.content-carrousel figure:nth-child(9) {
	transform: rotateY(320deg) translateZ(300px);
}
.content-carrousel figure:nth-child(10) {
	transform: rotateY(360deg) translateZ(300px);
}

.shadow {
	position: absolute;
	box-shadow: 0px 0px 20px 0px #000;
	border-radius: 1px;
}

.content-carrousel img {
	image-rendering: auto;
	transition: all 300ms;
	width: 100%;
	height: 100%;
}

.content-carrousel img:hover {/*画像ホバーでズーム*/
	transform: scale(1.2);
	transition: all 300ms;
}

@keyframes rotar {/*カルーセルのアニメーション*/
	from {
		transform: rotateY(0deg);
	}
	to {
		transform: rotateY(360deg);
	}
}

html

<section id="slideshow">
	<div class="entire-content">
		<div class="content-carrousel">
			<figure class="shadow"><img src="https://picsum.photos/200/300"/></figure>
			<figure class="shadow"><img src="https://picsum.photos/201/300"/></figure>
			<figure class="shadow"><img src="https://picsum.photos/202/300"/></figure>
			<figure class="shadow"><img src="https://picsum.photos/203/300"/></figure>
			<figure class="shadow"><img src="https://picsum.photos/204/300"/></figure>
			<figure class="shadow"><img src="https://picsum.photos/205/300"/></figure>
			<figure class="shadow"><img src="https://picsum.photos/206/300"/></figure>
			<figure class="shadow"><img src="https://picsum.photos/207/300"/></figure>
			<figure class="shadow"><img src="https://picsum.photos/208/300"/></figure>
		</div>
	</div>
</section>

via

3D Slider | Pure CSS

Share.

About Author

Comments are closed.