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

              
                <a href="#" class="toggle-link">
	<img src="https://brm.us/avatar" class="avatar" id="avatar1" height="100" width="100" />
</a>

<div id="modal">
	<h1>About Bramus!</h1>
	
	<img src="https://brm.us/avatar" class="avatar" id="avatar2" height="100" width="100" />
	
	<div>
		<p>Bramus Van Damme is a web developer from Belgium. From the moment he discovered <code>view-source</code> at the age of 14 <em>(way back in 1997)</em>, he <strong>fell in love with the web</strong> and has been tinkering with it ever since.</p>

		<p>With his company <a href="https://www.3rds.be/">3RDS</a> he works as a <strong>freelance developer</strong>, tackling both the frontend <em>(HTML, CSS, JS)</em> and the backend <em>(PHP, MySQL)</em>. <strong>His current focus is on JavaScript, React and React Native yet his love for CSS will never fade.</strong> Not limiting himself to only part of the stack, he also knows his way around supporting technologies <em>(HTTPS, DNS, Docker, Serverless, …)</em></p>

		<p>Before launching 3RDS, Bramus worked at several web agencies in various frontend en backend roles. For seven years he also was a <strong>Lecturer Web &amp; Mobile</strong> within the study programme Professional Bachelor ICT.</p>
	</div>
</div>
              
            
!

CSS

              
                html,
body {
	width: 100vw;
	height: 100vh;
	background: #123456;
}

* {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

body {
	display: grid;
	place-content: center;
}

.avatar {
	background: #ccc;
	width: 6em;
	height: auto;
	contain: paint; /* <-- DON'T FORGET THIS ONE! */
}

a.toggle-link .avatar {
	border-radius: 50%;
	border: 4px solid rgb(255 255 255 / 0.5);
}
a.toggle-link:hover .avatar {
	border-color: rgb(255 255 255 / 0.8);
}

#modal {
	position: absolute;
	background: #ccc;
	border: 4px solid #000;
	border-radius: 1em;

	display: none;
	grid-gap: 1em;
	overflow: hidden;
}

@media (orientation: portrait) {
	#modal {
		top: 10vh;
		right: 20vw;
		left: 20vw;
		bottom: 10vh;
	
		grid-template-columns: 1fr;
		grid-template-rows: 60vw 3em 1fr;
		grid-template-areas:
			"avatar"
			"title"
			"content";
	}
	
	#modal > .avatar {
		width: 100%;
	border-bottom: 4px solid #000;
	}
	
	#modal > h1 {
		text-align: center;
	}
	
	#modal > div {
		padding: 0 1rem;	
	}
}

@media (orientation: landscape) {
	#modal {
		top: 15vh;
		right: 20vw;
		left: 20vw;
		bottom: 15vh;
	
		grid-template-columns: 70vh 1fr;
		grid-template-rows: 4em 1fr;
		grid-template-areas:
			"avatar title"
			"avatar content";
	}
	
	#modal > .avatar {
		align-self: start;
		width: 100%;
	border-right: 4px solid #000;
	}
}

#modal > h1 {
	grid-area: title;
	margin: 0;
	align-self: end;
}
#modal > .avatar {
	grid-area: avatar;
}
#modal > div {
	font-size: 1.25em;
	grid-area: content;
	overflow-y: scroll;
}

#modal > div > * {
	margin-bottom: 1rem;
}

.show-modal .toggle-link {
	display: none;
}
.show-modal #modal {
	display: grid;
}
              
            
!

JS

              
                // @ref https://www.chromestatus.com/feature/5193009714954240
console.clear();

const transition = async () => {
	const modalShown = document.body.classList.contains('show-modal');
	
	if (document.documentTransition) {
		await document.documentTransition.prepare({
			rootTransition: modalShown ? "cover-down" : "cover-up",
		});
	}

	document.body.classList.toggle("show-modal");

	if (document.documentTransition) {
		await document.documentTransition
			.start().then(() => {
				console.log("transition finished");
			});
	}
}

document.querySelector("body").addEventListener("click", (e) => {
	e.preventDefault();
	e.stopPropagation();
		
	if (!document.body.classList.contains('show-modal')) {
		return;
	}
	
	if (e.target.tagName.toUpperCase() != "BODY") {
		return;
	}

	transition();
});

document.querySelector(".toggle-link").addEventListener("click", (e) => {
	e.preventDefault();
	e.stopPropagation();

	transition();
});

              
            
!
999px

Console