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

              
                <h1>Animate the Details HTML Element Using Pure CSS</h1>
<p class="note">*Requires Chrome Canary with "Experimental Web Platform Features" flag enabled.</p>

<details open class="details" name="CSS Weekly" style="--i: 1;">
	<summary class="details__summary">CSS Weekly Newsletter</summary>
	<div class="details__content">
		<p>Weekly hands-on guides that will help you stay up to date with CSS.</p>
		<p><a href="https://css-weekly.com" target="_blank">Subscribe Now »</a></p>
	</div>
</details>

<details class="details" name="CSS Weekly" style="--i: 2;">
	<summary class="details__summary">CSS Stickers</summary>
	<div class="details__content">
		<p>A set of beautiful, cute, and funny CSS stickers to showcase your love for CSS.</p>
		<p><a href="https://stickers.css-weekly.com" target="_blank">Check out CSS Stickers »</a></p>
	</div>
</details>

<details class="details" name="CSS Weekly" style="--i: 3;">
	<summary class="details__summary">Mastering Linting</summary>
	<div class="details__content">
		<p>A course that will help you get proficient with the best Linting tools, Prettier & Stylelint.</p>
		<p><a href="https://masteringlinting.com" target="_blank">Enroll Now »</a></p>
	</div>
</details>

<details class="details" name="CSS Weekly" style="--i: 4;">
	<summary class="details__summary">CSS Weekly YouTube Channel</summary>
	<div class="details__content">
		<p>Weekly hands-on guides that will help you stay up to date with CSS.</p>
	<p><a href="https://youtube.com/@cssweekly?sub_confirmation=1" target="_blank">Subscribe on YouTube »</a></p>
	</div>
</details>

              
            
!

CSS

              
                /* Page Style */
body {
	box-sizing: border-box;
	min-block-size: 100vb;
	padding: 2rem;
	font-family: sans-serif;
	font-size: 1.4rem;
	line-height: 1.5;
	color: hsl(261deg 100% 25%);
	background: linear-gradient(
		120deg,
		hsl(260deg 80% 50%),
		hsl(0deg 100% 50%)
	);
}

a {
	color: hsl(1deg 70% 50%);
}

h1 {
	max-inline-size: 40rem;
	margin-block: 2rem;
	margin-inline: auto;
	font-size: 3rem;
	line-height: 1.2;
	color: hsl(0deg 100% 95%);
	text-align: center;
	text-wrap: balance;
}

code {
	padding-block: 0.5rem;
	padding-inline: 1rem;
	font-size: 0.8em;
	color: hsl(0deg 100% 15%);
	white-space: nowrap;
	background: yellow;
	border-radius: 5px;
}

p {
	margin-block: 0.5rem;
}

p:last-child {
	margin-block-end: 0;
}

.note {
	max-inline-size: 40rem;
	margin-inline: auto;
	margin-block: 2rem 3rem;
	color: hsl(0 100% 85%);
	text-align: center;
	text-wrap: balance;
}

details {
	position: relative;
	max-inline-size: 40rem;
	padding: 1rem;
	margin-block: 1rem 0;
	margin-inline: auto;
	background-image: linear-gradient(
		to top left,
		hsl(260deg 80% 80%) 0,
		hsl(0deg 100% 95%)
	);
	border: 1px solid hsl(260deg 100% 95%);
	border-radius: 0.3rem;
}

summary {
	padding-inline: 2rem;
	position: relative;
	font-weight: 700;
	cursor: pointer;
}

/* Demo Code */
.details::details-content {
	display: block;
	margin-inline: 2rem;
	block-size: 0;
	overflow: hidden;
	transition-property: block-size, content-visibility;
	transition-duration: 0.5s;
	transition-behavior: allow-discrete;
}

.details[open]::details-content {
	/* Fallback for browsers that don't support calc-size() function */
	block-size: auto;
	
	/* calc-size() function allows transition to height: auto; */
	block-size: calc-size(auto, size);
}

/* List Item ::marker supports only some CSS properties, so we're using ::before pseudo-element instead */
summary::marker {
	content: '»';
	content: none;
}

summary::before {
	content: '»';
	position: absolute;
	inset-inline-start: 1rem;
	inset-block-start: -0.05rem;
	transition: rotate 0.2s;
}

.details[open] summary::before {
	rotate: 90deg;
	inset-block-start: 0.05rem;
}

              
            
!

JS

              
                // Pure CSS ❤️
// In-Depth Guide: https://youtu.be/idoaw75xjhU
              
            
!
999px

Console