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

              
                style.restyle
header.m
	h1.s5 CSS vertical rhythm
	p.s0 Testing an adaptive ruleset for vertical rhythm, responsive to the <code>font-size</code> of the parent container. Set the parent's <code>font-size</code> to whatever you want the vertical rhythm's base to be.

.splitter
	- for i in (0..2)
		div class='#{i == 0 ? 'g' : 'g v'}'
			.s0 #{i == 0 ? 'Unaligned' : 'Aligned'}
			.m
				- for i in (0..6)
					p class='s#{7-i}' #{7-i}: Jalapeno pepper and garlic add a fragrant zing.
					p.s0.serif For an infused oil, simply combine 7 parts oil with a pinch of sea salt and freshly ground black pepper to taste. Seal the jar and shake for 30 seconds, until the salt is fully dissolved in the oil. Uncap the jar and add 1 part ground herb or spice of your choice. Reseal the jar and shake until emulsified.
				p.s0 0: Jalapeno pepper and garlic add a fragrant zing.
				p.s-1 -1: Jalapeno pepper and garlic add a fragrant zing.
				p.s-2 -2: Jalapeno pepper and garlic add a fragrant zing.
				
p.s7 Copy the CSS here:
pre.s0

              
            
!

CSS

              
                * 
	margin: 0

body 
	font: 900 30.6px/1.7 arial, "Helvetica Neue", helvetica, sans-serif
	color: #444

header
	text-align: center
	margin: 1em auto 4em
	max-width: 560px

.splitter 
	display: flex
	& > * 
		flex-grow: 1
		flex-shrink: 1
		flex-basis: 0
		overflow: hidden

.g 
	font-size: 40px
	padding: 0 1em
	p
		white-space: nowrap
		&.serif
			white-space: normal

.g.v + .g.v
	background: repeating-linear-gradient(#ced, #ced 1em, #ccf 1em, #ccf 2em)

h1 
	text-decoration: underline

.serif 
	font-weight: normal
	font-family: georgia, palatino, 'Palatino Linotype', times, 'Times New Roman', serif

pre 
	font: inherit

              
            
!

JS

              
                // Note: this just automates the CSS writing. You don't need it in your final site, just copy the generated CSS at the bottom of the page :)

// "eem": effective em. The font size of the parent container.
const nOver = 7;
const nUnder = 2;
const scale = 1.25;
const ratio = 1.7; // Ratio of line height to font size.
const elements = {
	1: ['p'],
	2: ['h3', 'h4'],
	3: ['h2'],
	5: ['h1'],
}
const sizes = Array.from({length: nOver + nUnder + 1}, (_, i) => nOver - i);
const fontSizes = sizes.map(s => Math.pow(scale, s) / ratio);
const format = n => +n.toFixed(10);
const variables = [`:root {
${fontSizes.map((fontSize, i) => `\t--s${sizes[i]}: ${format(fontSize)}em;`).join('\n')}
}`];
// Note from the future: all of these were being overwritten anyway so
//  I removed them from the final stylesheet.
// const unalignedRules = [`${Object.values(elements).flat().sort().concat(sizes.map(s => `.s${s}`)).map(selector => `.m ${selector}`).join(', ')} {
// \tmargin: 0.8em 0 0.3em;
// }`];
const alignedRules = sizes.map((s, i) => {
  // Line height is 1eem. Base font size is 1eem / 1.7.
  const fontSize = fontSizes[i];
  let lineHeight;
  const reciprocal = lineHeight = 1 / fontSize;
  while (lineHeight < 1.3) lineHeight += reciprocal;
  // If the size gap between the line height and the text is greater than .5eem, skip the bottom margin.
  // Otherwise, add a margin of 1 eem.
  const marginBottom = (lineHeight - 1) * fontSize > 0.5 ? 0 : `${format(reciprocal)}em`;
  // However many ems the font size is (rounded down, min 1), that's how many eems we add on top.
  const marginTop = `${format(reciprocal * Math.max(1, Math.floor(fontSize)))}em`;
  const selectors = (elements[s] || []).concat(`.s${s}`);
  return `${selectors.join(', ')} {
\tfont-size: var(--s${s});
}
${selectors.map(selector => `.v ${selector}`).join(', ')} {
\tline-height: ${format(lineHeight)}em;
}
${selectors.map(selector => `.m ${selector}`).join(', ')} {
\tmargin: ${marginTop} 0 ${marginBottom};
}`;
});

document.querySelector('pre').textContent = document.querySelector('.restyle').textContent = variables.concat(alignedRules).join('\n');

              
            
!
999px

Console