Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ 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

Save Automatically?

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="fauxBody">
		<header id="top">
			<h1><a href="#">Site Title</a></h1>
			<button type="button" id="mainMenuOpen" tabindex="-1" hidden></button>
			<nav>
				<ul>
					<li><a href="#">Home</a></li>
					<li><a href="#">FAQ</a></li>
					<li><a href="#">Tutorial</a></li>
					<li><a href="#">Links</a></li>
					<li><a href="#">Forums</a></li>
					<li><a href="#" class="action">Sign In</a></li>
				</ul>
			</nav>
		</header>
		<main>
			<div class="hero">
				<section>
					<h2>This Ain't No Place For No Hero</h2>
					<p>
						Really not a fan of hero sections, but for testing it's a good space-waster.
					</p><p>
						Narrow the window to trigger the modal / "hamburger" menu.
					</p>
				</section>
			<!-- .hero --></div>
			<section>
				<h2>Short Change Hero</h2>
				<p>
					Yeah, I can't see where you comin' from<br>
					But I know just what you runnin' from<br>
					And what matters ain't the "Who's baddest"<br>
					But the ones who stop you fallin' from your ladder
				</p><p>
					When you're Feelin' like you're feelin' now<br>
					And doin' things just to please your crowd<br>
					When I love you like the way I love you<br>
					And I suffer but I ain't gonna cut you 'cause
				</p><p>
					This ain't no place for no hero<br>
					This ain't no place for no better man<br>
					This ain't no place for no hero<br>
					To call home
				</p><p>
					-- <cite>The Heavy</cite>
				</p>
			</section>
		</main>
		<footer>
			<hr>
			<a href="#top" class="backToTop">Back To Top</a>
			Mobile Menu Demo By
			<span>Jason M. Knight, Jan 2022</span>
		</footer>
	<!-- #fauxBody --></div>

              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css2?family=Poppins:wght@400;700&display=swap);

html,body,div,p,h1,h2,h3,h4,h5,h6,
ul,ol,li,dl,dt,dd,form,fieldset,caption,
table,tr,td,th,address,blockquote,img {
	margin:0;
	padding:0;
}

img, fieldset {
	border:none;
}

*, *:after, *:before {
	flex:1 0 auto; /* safari bugfix */
	box-sizing:border-box;
}

hr {
	display:none;
}

button, label {
	cursor:pointer;
}

html, body {
	height:100%;
}

body, button, input, table, textarea, select {
	font:normal 1em/1.5 "poppins",arial,helvetica,sans-serif;
}

#fauxBody {
	display:flex;
	flex-direction:column;
	height:100%;
	overflow:auto;
}

#top,
#fauxBody > footer {
	flex-grow:0;
	padding:1rem;
	background:#ACE;
}

.backToTop {
	float:right;
	margin-left:1.5em;
}

#top {
	display:flex;
	gap:1.5rem;
}

#top > nav {
	flex-grow:0;
}

#top > nav li {
	list-style:none;
	display:inline-block;
	margin-left:1rem;
}

h1 {
	font-size:1.5em;
	line-height:1.2;
}

#fauxBody > footer span {
	display:inline-block;
}

#top a,
#fauxBody > footer a {
	display:inline-block;
	text-decoration:none;
	color:#048;
	transition:transform 0.3s, color 0.3s, box-shadow 0.3s;
}

#top > nav a {
	padding:0.25em 0;
	line-height:1.3;
}

#top > nav a:focus,
#top > nav a:hover,
#fauxBody > footer a:focus,
#fauxBody > footer a:hover {
	color:#000;
	transform:scale(1.2);
}

#top > nav a.action {
	padding:0.25em 0.5em;
	border-radius:0.25em;
	box-shadow:0 0 0 0.0625rem #048;
}

#top > nav a.action:focus,
#top > nav a.action:hover {
	box-shadow:0 0 0 0.0625rem #000;
}

main > section,
.hero > section {
	padding:1rem clamp(1rem, 4vw, 2rem);
	max-width:40rem;
	margin:0 auto;
}

.hero {
	padding:min(25vh, 20vw) 0;
	background:url(https://source.unsplash.com/IM8ZyYaSW6g/1920x1280) center center no-repeat;
	background-size:cover;
}

main p {
	margin:1em 0;
}

@media (max-width:48rem) {
	#mainMenuOpen {
		display:block;
		flex-grow:0;
		font-size:1.8em;
		line-height:1;
		border:0;
		background:transparent;
		color:#048;
	}
	#mainMenuOpen:after {
		content:"\2630";
	}
	#mainMenuOpen + nav {
		position:fixed;
		top:0;
		left:-100%;
		width:100%;
		height:100%;
		overflow:auto;
		display:flex;
		align-items:center;
		justify-content:center;
		opacity:0;
		background:#DEFD;
		transition:left 0s 0.5s, opacity 0.5s;
	}
	#mainMenuOpen:focus + nav,
	#mainMenuOpen + nav:focus-within {
		left:0;
		opacity:1;
		transition:left 0s, opacity 0.5s;
	}
	#mainMenuOpen + nav ul {
		flex-grow:0;
		display:flex;
		flex-wrap:wrap;
		position:relative;
		top:-50vh;
		max-width:14em;
		margin:auto;
		overflow:hidden;
		background:#8AC;
		border-radius:0.5em;
		box-shadow:
			0 0 1px 1px #0008,
			0 0.25em 0.5em 0.25em #0002;
		transition:top 0.5s;
	}
	#mainMenuOpen:focus + nav ul,
	#mainMenuOpen + nav:focus-within ul {
		top:0;
	}
	#mainMenuOpen + nav li {
		width:34%;
		margin:0 0.5em 0.5em;
	}
	#mainMenuOpen + nav li:nth-child(even) {
		margin-left:0;
	}
	#top > nav a,
	#top > nav a.action {
		display:block;
		padding:0.5em 1em;
		text-align:center;
		background:#FFF;
		box-shadow:none;
		border-radius:0.25em;
	}
	#top > nav a:focus,
	#top > nav a:hover,
	#top > nav a.action:focus,
	#top > nav a.action:hover {
		transform:scale(1.1);
		background:#ACE;
		box-shadow:none;
	}
	#mainMenuOpen + nav ul:before {
		content:"Main Menu";
		display:block;
		width:100%;
		padding:0.25em 1em;
		margin-bottom:0.5em;
		font-weight:bold;
		background:#ACE;
		border-bottom:1px solid #0128;
	}
	#mainMenuOpen + nav ul:after {
		content:"\1F5D9";
		display:block;
		position:absolute;
		top:0.125rem;
		right:0.5rem;
		font-size:1.5rem;
		line-height:1;
	}
}
              
            
!

JS

              
                {
  const opener = document.getElementById("mainMenuOpen");
  document.addEventListener("keydown", (event) => {
    if (event.key === "Escape") opener.blur();
    console.log("dafug", event.key);
  } );
  
  opener.addEventListener("touchstart", () => {
		opener.focus();
	} );
  opener.nextElementSibling.addEventListener("touchstart",  () => {
		opener.blur();
	} );
}
              
            
!
999px

Console