<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="/assets/reset.css" rel="stylesheet">
<link href="setup.css" rel="stylesheet">
<link href="style.css" rel="stylesheet">
<script defer src="script.js"></script>
</head>
<body>
<section>
<p>I’ve just added some text here to have another element, and also added some CSS to style it a bit—nothing too fancy.</p>
</section>
<section>
<p>I’ve just added some text here to have another element, and also added some CSS to style it a bit—nothing too fancy.</p>
</section>
<section>
<p>I’ve just added some text here to have another element, and also added some CSS to style it a bit—nothing too fancy.</p>
</section>
<section>
<p>I’ve just added some text here to have another element, and also added some CSS to style it a bit—nothing too fancy.</p>
</section>
<section>
<p>I’ve just added some text here to have another element, and also added some CSS to style it a bit—nothing too fancy.</p>
</section>
<section>
<p>I’ve just added some text here to have another element, and also added some CSS to style it a bit—nothing too fancy.</p>
</section>
<section>
<p>I’ve just added some text here to have another element, and also added some CSS to style it a bit—nothing too fancy.</p>
</section>
<section>
<p>I’ve just added some text here to have another element, and also added some CSS to style it a bit—nothing too fancy.</p>
</section>
<section>
<p>I’ve just added some text here to have another element, and also added some CSS to style it a bit—nothing too fancy.</p>
</section>
<section>
<p>I’ve just added some text here to have another element, and also added some CSS to style it a bit—nothing too fancy.</p>
</section>
<section>
<p>I’ve just added some text here to have another element, and also added some CSS to style it a bit—nothing too fancy.</p>
</section>
<section>
<p>I’ve just added some text here to have another element, and also added some CSS to style it a bit—nothing too fancy.</p>
</section>
<section>
<p>I’ve just added some text here to have another element, and also added some CSS to style it a bit—nothing too fancy.</p>
</section>
<section>
<p>I’ve just added some text here to have another element, and also added some CSS to style it a bit—nothing too fancy.</p>
</section>
</body>
</html>
let highlightClass = 'highlight'
let highlightBlock = document.querySelector('section:nth-child(8)')
let sectionObserver = new IntersectionObserver((entries) => {
let [entry] = entries
if (entry.isIntersecting) {
highlightBlock.classList.add(highlightClass)
} else {
highlightBlock.classList.remove(highlightClass)
}
})
sectionObserver.observe(highlightBlock)