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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                <h1>Flexbox Holy Albatross w/ 2 Columns</h1>

<h2>2 Columns</h2>

<p>When the container is large, these elements display as 2 columns. Once the <em>container</em> (not the viewport) shrinks below 600px, it collapses to one column.</p>

<div class="holy-albatross holy-albatross--2-columns">
	<div>1</div>
	<div>2</div>
	<div>3</div>
	<div>4</div>
</div>

<h2>Default Behavior</h2>

<p>For reference, the default behavior of the Flebox Holy Albatross is to simply set equal-width columns. However many items there are in your container, that’s how many columns you’ll see.</p>

<div class="holy-albatross">
	<div>1</div>
	<div>2</div>
	<div>3</div>
	<div>4</div>
</div>

<h2>References</h2>
<ul>
	<li><a href="http://www.heydonworks.com/article/the-flexbox-holy-albatross-reincarnated" target="_blank" rel="noopener">HeydonWorks: The Flexbox Holy Albatross Reincarnated</a></li>
	<li><a href="http://www.heydonworks.com/article/the-flexbox-holy-albatross" target="_blank" rel="noopener">HeydonWorks: The Flexbox Holy Albatross</a></li>
	<li><a href="https://snook.ca/archives/html_and_css/understanding-the-flexbox-albatross" target="_blank" rel="noopener">Snook.ca: Understanding the Albatross</a></li>
</ul>

              
            
!

CSS

              
                // 🦅 Albatross Settings
$albatross-max-width: 600px;
$albatross-margin-x: 20px;
$albatross-margin-y: 10px;

.holy-albatross {
	display: flex;
	flex-wrap: wrap;
	margin: (-$albatross-margin-y) (-$albatross-margin-x);
}

// 📝 Max-Width
// To split into columns at a specific container size, add the negative margin to your calculations.
.holy-albatross > * {
	flex-basis: calc((#{$albatross-max-width} + (#{$albatross-margin-x} * 2) - 100%) * 999);
	flex-grow: 1;
	margin: $albatross-margin-y $albatross-margin-x;
}

// 🔮 2 Columns
// To force a minimum number of columns, multiply margin * number of columns (e.g., 20px * 2 columns = 2rem).
.holy-albatross--2-columns > * {
	min-width: calc(50% - (#{$albatross-margin-x} * 2));
}

// Decorations
body {
	line-height: 1.4;
	tab-size: 4;
}

div > div {
	padding: 20px;
	background: #eee;
	box-sizing: border-box;
}

              
            
!

JS

              
                
              
            
!
999px

Console