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

              
                <header>
	<p><code>IntersectionObserver</code> is overkill. Just  
	<a href="https://codepen.io/gunnarbittersmann/pen/rNrgovg?editors=1000" target="_top">compare  <code>scrollHeight</code> with <code>clientHeight</code></a></p>
</header>
<main lang="de">
	<h1>Allgemeine Erklärung der Menschenrechte</h1>
	<section id="article1">
		<h2>Artikel 1: Freiheit, Gleichheit, Brüderlichkeit</h2>
		<p>Alle Menschen sind frei und gleich an Würde und Rechten geboren. Sie sind mit Vernunft und Gewissen begabt und sollen einander im Geist der Brüderlichkeit begegnen.</p>
	</section>
	<section id="article2">
		<h2>Artikel 2: Verbot der Diskriminierung</h2>
		<p>Jeder hat Anspruch auf die in dieser Erklärung verkündeten Rechte und Freiheiten ohne irgendeinen Unterschied, etwa nach Rasse, Hautfarbe, Geschlecht, Sprache, Religion, politischer oder sonstiger Überzeugung, nationaler oder sozialer Herkunft, Vermögen, Geburt oder sonstigem Stand.</p>
		<p>Des weiteren darf kein Unterschied gemacht werden auf Grund der politischen, rechtlichen oder internationalen Stellung des Landes oder Gebiets, dem eine Person angehört, gleichgültig ob dieses unabhängig ist, unter Treuhandschaft steht, keine Selbstregierung besitzt oder sonst in seiner Souveränität eingeschränkt ist.</p>
	</section>
	<section id="article3">
		<h2>Artikel 3: Recht auf Leben und Freiheit</h2>
		<p>Jeder hat das Recht auf Leben, Freiheit und Sicherheit der Person.</p>
	</section>
	<section id="article4">
		<h2>Artikel 4: Verbot der Sklaverei und des Sklavenhandels</h2>
		<p>Niemand darf in Sklaverei oder Leibeigenschaft gehalten werden; Sklaverei und Sklavenhandel sind in allen ihren Formen verboten.</p>
	</section>
</main>
              
            
!

CSS

              
                * { box-sizing: border-box }

html {
	font: 1em/1.4em Calibri, sans-serif;
}

header {
	margin-bottom: 3em;
}

section {
	margin: 0.7em 0;
	max-width: 30em;
	height: 8em;
	padding: 0.3em 1em;
	overflow: auto;
	outline: thin solid silver;
}

.overflow {
	outline: thick solid red;
}

h1, h2, p {
	margin: 0;
}

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

h2 {
	font-size: 1.2em;
}
              
            
!

JS

              
                const sectionElements = document.querySelectorAll('section');

for (let sectionElement of sectionElements) {
	sectionElement.intersectionObserver = new IntersectionObserver(
		(entries) => {
			if (entries[0].intersectionRatio < 1) {
				sectionElement.classList.add('overflow');
			}
		},
		{
			root: sectionElement,
		},
	);
	
	sectionElement.intersectionObserver.observe(sectionElement.lastElementChild);
}
              
            
!
999px

Console