Styling <details> : Horizontal Accordion (no animation)

Demo

🚤

Boating

Port mutiny draught handsomely ye furl flogging line shrouds hulk. Spirits Plate Fleet code of conduct.

⚓️

Anchoring

Ahoy league hands Sea Legs keelhaul salmagundi fire ship crimp Privateer galleon. Booty boom yard boatswain quarter.

🎣

Fishing

No prey, no pay heave down splice the main brace furl cable snow walk the plank chase guns piracy bucko.

🔦

Lighthouses

Deadlights squiffy salmagundi cable pinnace parrel topsail Corsair Arr mizzenmast.

🪸

Reefs

Keel yard poop deck brigantine gaff six pounders bring a spring upon her cable interloper lad pink.

Demo for https://developer.chrome.com/blog/styling-details , built after https://codepen.io/jakob-e/full/MWzRjNe

The Code

UI

.accordion-wrapper {
	display: flex;
	flex-direction: row;
	gap: 1rem;
}

details {
	display: flex;
	flex-direction: row;
	
	height: 30rem;
	border-radius: 2rem;
	overflow: hidden;
	
	/* To make the image positioning work …*/
	position: relative;
	z-index: 1;
	
	/* Hide marker */
	::marker {
		content: '';
	}
	
	/* The image is tucked in the summary, because otherwise it would be hidden when not [open] as it ends up in the ::details-content pseudo */
	summary img {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		object-fit: cover;
		z-index: -1;
		transition: filter 0.5s ease;
	}
	/* Animate the image */
	&[open] summary img {
		filter: brightness(0.5);
	}
	
	summary {
		padding: 1rem 1em;
		width: 5rem;
		flex-shrink: 0; /* Prevent shrinking */
		text-align: center;
	}
	
	.details-content-wrapper {
		padding: 1.5rem 1em;
		width: 300px; /* Fixate the width of the content so that the text doesn’t wrap/unwrap when expanding the details */
	}
}

.details-content-wrapper {
	/* Animate-in the text when open */
	p {
		transform: translateY(2rem);
		opacity: 0;
		transition: all 0.5s ease;
		transition-delay: 0.5s;
	}
	
	[open] & p {
		transform: none;
		opacity: 1;
		transition-delay: 0.5s;
	}
}