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 id="popup" class="popup">
	<div class="popup-content">
		<span style="font-size:70px;">&#128172;</span>
		<p class="popup-text">Hey there! Click on one of the thumbs or hover over the card for some magic!</p>
	</div>
</div>
<div id="image-container"></div>
<div class="container">
	<div class="tilt-card" data-tilt>
		<div class="tilt-card-front">

		</div>
		<div class="tilt-card-back">
		</div>
	</div>
</div>
              
            
!

CSS

              
                /* Resetting some basic styles */
* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

/* Fullscreen container */
body {
	background-color: #1a1919;
	font-family: "Roboto", sans-serif;
	display: flex;
	justify-content: center;
	align-items: center;
	height: 100vh;
	margin: 0;
	overflow: hidden;
	position: relative;
}

/* pop-up */

.popup {
	position: fixed;
	bottom: -100px;
	right: 10px;
	width: 300px;
	height: 170px;
	background-color: #0170b9;
	border-radius: 8px;
	display: flex;
	justify-content: center;
	align-items: center;
	opacity: 0;
	transition: bottom 0.5s ease, opacity 0.5s ease;
	z-index: 9999;
}

.popup-content {
	padding: 1rem 0.6rem;
	padding-bottom: 1.5rem;
	text-align: center;
}

.popup-text {
	font-size: 13px;
	font-weight: 400;
	color: #fff;
	letter-spacing: 1px;
	text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
}

.popup.show {
	bottom: 10%;
	opacity: 1;
}

/* end pop-up */

/* Container for the 3D effect */
.container {
	display: flex;
	justify-content: center;
	align-items: center;
	perspective: 1200px;
}

/* 3D card setup */
.tilt-card {
	width: 300px;
	height: 400px;
	position: relative;
	transform-style: preserve-3d;
	transition: transform 0.4s ease-in-out, box-shadow 0.3s ease,
		background-color 0.3s ease;
	cursor: pointer;
	border-radius: 10px;
	box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
}

.tilt-card:hover {
	transform: scale(1.1) rotateX(15deg) rotateY(15deg);
	box-shadow: 0 25px 45px rgba(0, 0, 0, 0.3);
	background-color: transparent;
}

/* Front face of the card */
.tilt-card-front,
.tilt-card-back {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	backface-visibility: hidden;
	display: flex;
	justify-content: center;
	align-items: center;
	border-radius: 10px;
	transition: transform 0.3s ease, background-color 0.3s ease;
	color: #fff;
}

.tilt-card-front {
	background-color: #007bff;
	background-image: url(https://iili.io/2gvvroG.jpg);
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
	padding: 20px;
	transform: rotateY(0deg);
	transition: transform 0.3s ease;
}

.tilt-card-back {
	background-color: #f1c40f;
	background-image: url(https://iili.io/2gvvUts.jpg);
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
	padding: 20px;
	transform: rotateY(180deg);
}

.tilt-card:hover .tilt-card-front {
	transform: rotateY(180deg);
}

.tilt-card:hover .tilt-card-back {
	transform: rotateY(360deg);
}

/* Hover effects on text */
h2,
h3 {
	font-size: 24px;
	text-align: center;
	transition: transform 0.3s ease, color 0.3s ease;
	color: #269ceb;
	letter-spacing: 1px;
	text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.9);
	background-color: black;
}

p {
	font-size: 16px;
	text-align: center;
	margin-top: 10px;
	font-weight: 300;
	transition: transform 0.3s ease, color 0.3s ease;
}

/* Hover effects on text */
.tilt-card:hover h2,
.tilt-card:hover p {
	transform: scale(1.1);
	color: #fff;
}

/* Image Container Styling */
#image-container {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	pointer-events: none; /* Prevent interaction with images */
}

/* Styling voor de floating images */
.image-item {
	position: absolute;
	width: 150px;
	height: 100px;
	border-radius: 10px;
	animation-play-state: running; /* Voor hover-effect */
	cursor: pointer; /* Laat zien dat het klikbaar is */
	pointer-events: auto; /* Zorgt ervoor dat hover wordt gedetecteerd */
	z-index: 10; /* Hoge waarde om boven andere elementen te komen */
}

.image-item:hover {
	animation-play-state: paused;
}

/* Styling voor de lightbox-overlay */
.lightbox-overlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100vw;
	height: 100vh;
	background-color: rgba(0, 0, 0, 0.8); /* Donkere achtergrond */
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 1000; /* Zorg ervoor dat het altijd bovenaan staat */
}

/* Styling voor de lightbox-afbeelding */
.lightbox-overlay img {
	max-width: 80%;
	max-height: 80%;
	border: 2px solid white; /* Optionele rand rond de afbeelding */
	box-shadow: 0 0 20px rgba(255, 255, 255, 0.5); /* Optionele schaduw */
	cursor: pointer; /* Laat zien dat je kunt klikken om te sluiten */
}

              
            
!

JS

              
                // pop-up
window.onload = () => {
	const popup = document.getElementById("popup");

	// Show the popup
	setTimeout(() => {
		popup.classList.add("show");
	}, 500); // Delay the show for 0.5 seconds for the smooth effect

	// Hide the popup after 6 seconds
	setTimeout(() => {
		popup.classList.remove("show");
	}, 10500); // 10 seconds + 0.5 seconds for the fade out effect
};

//end pop-up

const imageContainer = document.getElementById("image-container");
const imagePaths = [
	"https://iili.io/2gvv4Vf.jpg",
	"https://iili.io/2gvvLSS.jpg",
	"https://iili.io/2gvvtR9.jpg",
	"https://iili.io/2gvvDNe.jpg",
	"https://iili.io/2gvviKl.jpg",
	"https://iili.io/2gvv6P4.jpg",
	"https://iili.io/2gvvbDu.jpg",
	"https://iili.io/2gvvsl2.jpg",
	"https://iili.io/2gvvLSS.jpg",
	"https://iili.io/2gvvSNn.jpg"
];

// Create image elements
imagePaths.forEach((path) => {
	const img = document.createElement("img");
	img.src = path;
	img.classList.add("image-item");

	// Set random positions
	img.style.left = `${Math.random() * 100}vw`; // Spread out the images
	img.style.top = `${Math.random() * 90}vh`;

	// Apply both animations: float first, then rotate
	img.style.animation = `float ${
		Math.random() * 4 + 3
	}s ease-in-out infinite, rotateAfterFloat 3s ease-in-out ${
		Math.random() * 2 + 2
	}s 1`;

	imageContainer.appendChild(img);

	// Pause floating animation on hover
	img.addEventListener("mouseover", () => {
		console.log("Hovering over an image!");
		img.style.animationPlayState = "paused";
	});

	img.addEventListener("mouseout", () => {
		img.style.animationPlayState = "running";
	});

	// Open lightbox on click
	img.addEventListener("click", (e) => {
		e.stopPropagation(); // Prevent click event from bubbling up
		openLightbox(img.src);
	});
});

// Add the floating and rotation animations to the head of the document
const style = document.createElement("style");
style.innerHTML = `
  @keyframes float {
    0% { transform: translate(0, 0); }
    50% { transform: translate(30px, 30px); }
    100% { transform: translate(0, 0); }
  }

  @keyframes rotateAfterFloat {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }

  .image-item {
    position: absolute;
    width: 150px;
    height: 100px;
    animation-play-state: running; /* Allow hover to pause animation */
  }
`;
document.head.appendChild(style);

// Function to open a lightbox
function openLightbox(imageSrc) {
	// Create a lightbox overlay
	const lightboxOverlay = document.createElement("div");
	lightboxOverlay.classList.add("lightbox-overlay");

	// Add the image to the lightbox
	const lightboxImage = document.createElement("img");
	lightboxImage.src = imageSrc;
	lightboxImage.classList.add("lightbox-image");

	// Close lightbox on click
	lightboxOverlay.addEventListener("click", () => {
		document.body.removeChild(lightboxOverlay);
	});

	lightboxOverlay.appendChild(lightboxImage);
	document.body.appendChild(lightboxOverlay);
}

// Lightbox Styling (additional CSS rules for the lightbox)
const lightboxStyle = document.createElement("style");
lightboxStyle.innerHTML = `
  .lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.8); /* Dark background */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
  }

  .lightbox-image {
    max-width: 80%;
    max-height: 80%;
    border: 2px solid white; /* Optional border */
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5); /* Optional shadow */
    cursor: pointer; /* Show that it can be clicked to close */
  }
`;
document.head.appendChild(lightboxStyle);

              
            
!
999px

Console