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-top">
	<div class="book">
		<img src="https://www.creatopy.com/blog/wp-content/uploads/2020/08/The-Little-Prince-Book-Cover-389x600.jpg" alt="Book Cover">
	</div>

	<div class="book">
		<img src="https://images-na.ssl-images-amazon.com/images/S/compressed.photo.goodreads.com/books/1472119680i/27833670.jpg" alt="Book Cover">
	</div>
</div> -->

<div class="container-top">
	<div class="book small">
		<img src="https://images-na.ssl-images-amazon.com/images/S/compressed.photo.goodreads.com/books/1472119680i/27833670.jpg" alt="Book Cover">
	</div>
	<div class="book small">
		<img src="https://www.creatopy.com/blog/wp-content/uploads/2020/08/The-Little-Prince-Book-Cover-389x600.jpg" alt="Book Cover">
	</div>
	<div class="book small">
		<img src="https://images.ctfassets.net/adaoj5ok2j3t/3sjuW1zsFOkQGK6kO8AuC6/6c9b4699d21ae69ff26fefc428a47d75/Norwegian_Wood.jpg" alt="Book Cover">
	</div>
	<div class="book small">
		<img src="https://m.media-amazon.com/images/I/81zihPTaXhL._AC_UF1000,1000_QL80_.jpg" alt="Book Cover">
	</div>
	
</div>

<div class="container-top">
	<div class="book small">
		<img src="https://www.ynharari.com/wp-content/uploads/2017/01/Harari_Homo-deus_m.jpg" alt="Book Cover">
	</div>
	<div class="book small">
		<img src="https://ik.imagekit.io/panmac/tr:f-auto,di-placeholder_portrait_aMjPtD9YZ.jpg,w-270/edition/9781509843527.jpg" alt="Book Cover">
	</div>
	<div class="book small">
		<img src="https://m.media-amazon.com/images/I/81wOob8L2hL._AC_UF1000,1000_QL80_.jpg" alt="Book Cover">
	</div>
	<div class="book small">
		<img src="https://m.media-amazon.com/images/I/91mZxsEw-zL._AC_UF1000,1000_QL80_.jpg" alt="Book Cover">
	</div>
</div>

<div class="title"><h3> // Experiments with animation:</h3></div>

<div class="container-top">
	<div class="book small book-fade book-three-d">
		<img src="https://www.ynharari.com/wp-content/uploads/2017/01/Harari_Homo-deus_m.jpg" alt="Book Cover">
	</div>
	<div class="book small book-fade book-hover-open">
		<img src="https://ik.imagekit.io/panmac/tr:f-auto,di-placeholder_portrait_aMjPtD9YZ.jpg,w-270/edition/9781509843527.jpg" alt="Book Cover">
	</div>
	<div class="book-wrapper">
		<div class="book-depth"></div>
		<div class="book-depth-bottom"></div>
		<div class="book small book-hover-open three-d">
			<img src="https://m.media-amazon.com/images/I/81wOob8L2hL._AC_UF1000,1000_QL80_.jpg" alt="Book Cover">
		</div>
	</div>

	<div class="book-wrapper">
		<div class="book-depth"></div>
		<div class="book-depth-bottom"></div>
		<div class="book small book-fade book-hover-open three-d">
			<img src="https://m.media-amazon.com/images/I/91mZxsEw-zL._AC_UF1000,1000_QL80_.jpg" alt="Book Cover">
		</div>
	</div>
</div>

              
            
!

CSS

              
                $book-width: 300px;
$book-aspect-ratio: 1.5;
$small-book-width: 150px;

.book {
	position: relative;
	width: $book-width;
	height: calc($book-width * $book-aspect-ratio);
	margin: 10px;
	overflow: hidden;
	border-radius: 6px;
	border-bottom-left-radius: 0;
	border-top-left-radius: 0;
	box-shadow: -4px 4px 12.4px rgba(0, 0, 0, 0.25);
	z-index: 2;
	img {
		display: block;
		width: 100%;
		height: 100%;
		object-fit: cover;
	}
	&.small {
		width: $small-book-width;
		height: calc($small-book-width * $book-aspect-ratio);

		&::after {
			width: $small-book-width;
			height: 100%;
			background: linear-gradient(
				270deg, 
				rgba(255, 255, 255, 0.12) 0%, 
				rgba(230, 230, 230, 0.2) 2%, 
				rgba(200, 200, 200, 0.30) 8%, 
				rgba(143, 143, 143, 0.02) 80%, 
				rgba(120, 120, 120, 0.17) 92.5%, 
				rgba(0, 0, 0, 0.3) 93.5%, 
				rgba(115, 115, 115, 0.1) 95%, 
				rgba(159, 145, 145, 0.04) 99%, 
				rgba(0, 0, 0, 0.6) 99.04%, 
				rgba(0, 0, 0, 0.23) 98%
			);
		}
	}

	&::after {
		content: '';
		position: absolute;
		top: 0;
		left: 0;
		width: $book-width;
		height: 100%;
		z-index: 1;
		pointer-events: none;
		background: linear-gradient(
			270deg, 
			rgba(255, 255, 255, 0.12) 0%, 
			rgba(230, 230, 230, 0.18) 6%, 
			rgba(218, 218, 218, 0.04) 8%, 
			rgba(143, 143, 143, 0) 80%, 
			rgba(131, 131, 131, 0.11) 92.5%, 
			rgba(0, 0, 0, 0.2) 93.5%, 
			rgba(115, 115, 115, 0) 95%, 
			rgba(255, 255, 255, 0.02) 99%, 
			rgba(0, 0, 0, 0.2) 99.04%,
			rgba(0, 0, 0, 0.2) 100%
		);
	}
	
	&::before {
		content: '';
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		z-index: 1;
		pointer-events: none;
	}
}

/* 
*********************************************************************************************EXPERIMENTS************************************************************************************************************
*/

.book-three-d {
	cursor: pointer;
	transform-origin: left center;
	transition: opacity 0.5s ease, filter 0.5s ease, transform 0.4s ease, box-shadow 0.4s ease;
	&:hover {
		transform: perspective(800px) rotateY(-25deg) rotateX(10deg) translateX(10px) translateZ(16px);
		box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
	}
}


// FADE
.book-fade {
	// Initially faded state
	opacity: 0.5;
	filter: grayscale(100%);
	// 

	&:hover {
		opacity: 1;
		filter: grayscale(0%);
	}
}

// ONE AXIS OPEN
.book-hover-open {
  cursor: pointer;
  transform-origin: left center;
  transition: transform 0.4s ease, box-shadow 0.4s ease;

  &:hover {
    transform: perspective(800px) rotateY(-25deg);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);

    &.three-d {
      transform: perspective(800px) rotateY(-25deg) rotateX(10deg) translateX(10px) translateZ(16px);
    }
  }
}

// THREE AXIS OPEN
.book-wrapper {
	position: relative;
	display: inline-block;
	border-radius: 6px;
	margin: 10px;

	&:hover {
		.book-depth {
			transform: perspective(700px) rotateY(25deg) rotateX(-6deg) translateX(2px) translateZ(-18px) skewY(20deg);
			right: -22px;
			height: 258px;
			top: -9px;
			bottom: -9px;
			opacity: 1;
		}
		.book-depth-bottom {
			transform: perspective(700px) rotateY(-25deg) rotateX(6deg) translateX(2px) translateZ(-18px) skewY(4deg) skewX(55deg) scaleY(1) scaleX(1);
			width: 189px;
			top: 231px;
			left: -39px;
			opacity: 1;
		}
	}

	.book {
		&.book-hover-open.three-d {
			overflow: visible;
			margin: 0;
		}
	}
}

.book-depth, .book-depth-bottom {
	position: absolute;
	right: 0;
	width: 13px; // Adjust width based on the thickness you want
	opacity: 0;
	background: linear-gradient(
		to left,
		rgba(255, 255, 255, 0.9) 0%,
		rgba(230, 230, 230, 0.8) 50%,
		rgba(200, 200, 200, 0.7) 100%
	);
	box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
	z-index: 1;
	pointer-events: none;
	transform: perspective(1000px) translateX(-15px) translateZ(0px);
	transform-origin: left center;
	transition: 
		transform 0.3s ease, 
		top 0.3s ease, 
		right 0.3s ease, 
		height 0.3s ease,
		opacity 0.2s ease;
}

.book-depth {
	top: 10px;
	height: 200px;
}

.book-depth-bottom {
	bottom: 10px;
	height: 13px;
	width: 100px;
	top: 200px;
	transform-origin: right bottom;
	transform: perspective(1000px) rotateX(90deg) scaleY(0);
	background: linear-gradient(
		to bottom,
		rgba(255, 255, 255, 0.9) 0%,
		rgba(230, 230, 230, 0.8) 50%,
		rgba(200, 200, 200, 0.7) 100%
	);
	transition: transform 0.8s ease, 
		top 0.4s ease, 
		right 0.4s ease, 
		height 0.5s ease;
}


// PAGE STUFF
body {
	display: flex;
	justify-content: center;
	flex-direction: column;
	align-items: center;
	height: 100%;
	margin: 100px 0;
	background-color: #121212;
	.title {
		display: flex;
		align-items: left;
		h3 {
			font-family: Inter;
			color: #0c670c90;
			font-style: italic;
		}
	}
}

.container-top {
	display: flex;
	flex-direction: row;
	margin-bottom: 40px;
}
              
            
!

JS

              
                
              
            
!
999px

Console