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

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

              
                <main class="demo">
	<h1>🔮 Breakout Overflow Scrolling</h1>
	<p>Quick demo of how you can use viewport units + some good old fashioned inline-block elements to make a scrollable section that overflows its container.</p>
	<p>Shoutout to <a href="https://codepen.io/jakob-e/pen/YbrRYN" target="_blank" rel="noopener">jakob-e for his breakout class</a>!</p>
	<ul class="overflow-scrolling">
		<li><a href="#" target="_blank" rel="noopener">Link #1</a></li>
		<li><a href="#" target="_blank" rel="noopener">Link #2</a></li>
		<li><a href="#" target="_blank" rel="noopener">Link #3</a></li>
		<li><a href="#" target="_blank" rel="noopener">Link #4</a></li>
		<li><a href="#" target="_blank" rel="noopener">Link #5</a></li>
		<li><a href="#" target="_blank" rel="noopener">Link #6</a></li>
		<li><a href="#" target="_blank" rel="noopener">Link #7</a></li>
		<li><a href="#" target="_blank" rel="noopener">Link #8</a></li>
		<li><a href="#" target="_blank" rel="noopener">Link #9</a></li>
		<li><a href="#" target="_blank" rel="noopener">Link #10</a></li>
	</ul>
</main>

              
            
!

CSS

              
                /* ------------------------------ */
/* Base                           */
/* ------------------------------ */

html {
	box-sizing: border-box;
	background: black;
}

*,
::after,
::before {
	box-sizing: inherit;
}

body {
	margin: 0;
	line-height: 1.4;
	tab-size: 4;
}

main {
	display: block; /* Fix IE rendering main as inline */
	max-width: 42rem;
	min-height: 100vh;
	margin: auto;
	padding: 2rem 1rem 5rem;
	background: white;
}

h1 {
	margin-top: 0;
}

/* ------------------------------ */
/* 🔮 Overflow Scrolling          */
/* ------------------------------ */

/*
1. Use vw + % to break the element outside of its container.
2. Make the overflow scrollable.
3. Prevent the elements from wrapping.
4. Reset font-size to avoid extra whitespace rendering between list items.
	- Note: You *could* add HTML comments to remove the space too, but... ¯\_(ツ)_/¯
5. Use inline-block to have all the items sit on the same line.
6. Reset font-size back to its natural size.
 */
.overflow-scrolling {
	display: block;
	margin: 0 calc(50% - 50vw); /* 1 */
	padding: 0 calc(50vw - 50%);
	overflow: auto; /* 2 */
	white-space: nowrap; /* 3 */
	font-size: 0; /* 4 */
	list-style: none;
}

.overflow-scrolling li {
	display: inline-block; /* 5 */
	font-size: 1rem; /* 6 */
}

.overflow-scrolling li:not(:last-child) {
	margin-right: 1rem;
}

.overflow-scrolling a {
	display: block;
	min-width: 10rem;
	padding: 1rem;
	background: yellow;
	text-align: center;
}

              
            
!

JS

              
                
              
            
!
999px

Console