Pen Settings



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


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


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.


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.


                <div class="container">
	<div class="status status--invisible">
		Nothing is visible, scroll!
	<div class="item">Item 1</div>
	<div class="item">Item 2</div>
	<div class="item">Item 3</div>
	<div class="item">Item 4</div>
	<div class="item">Last item</div>


                // Intersect items
.item {
	margin-top: 200vh;
	padding: 50px 30px;
	font-weight: 500;
  font-size: 16px;
  text-align: center;
	color: #fff;
	background-color: #312671;
	&:nth-child(3) {
		padding: 100px 30px;
		background-color: #4cb6c3;
	&:nth-child(4) {
		padding: 30px;
		background-color: #b92073;
	&:nth-child(5) {
		padding: 200px 30px;
		background-color: #d46e14;

// Status box
.status {
	position: fixed;
	top: 0; 
	right: 0;
  padding: 15px 30px 12px;
  color: #fff;
	text-align: center;
	&--visible {
		background-color: #459845;
	&--invisible {
		background-color: #cc4848;

.container {
	height: 100vh;
	overflow: auto;
	font-size: 12px;
	font-weight: 200;
	text-transform: uppercase;
	letter-spacing: 2px;
	background-color: #09061B;



                // See a super simple version here

const statusBox = document.querySelector('.status');
let intersectItem = document.querySelectorAll('.item'), i;
let visiblity = 'invisible';
let statusText = 'Nothing is visible, scroll!';

const iObserver = new IntersectionObserver(items => {

  // Intersecting? (is the element in the available viewport)
  if (items[0].isIntersecting) {
		// Log visibility
    console.log('Visible? Yes');

    // Time when intersect occured (relative to page load)
    console.log('When? After ' + milliToSeconds(items[0].time));

    // Position values
		// Element that is visible
		// Update status vars
		visiblity = 'visible';
    statusText = items[0].target.textContent + ' is visible';

  } else {
    console.log('Visible? No')
    visiblity = 'invisible';
    statusText = 'Nothing is visible, scroll!';


  // Update status

// Loop through and observe intersect items
for (i = 0; i < intersectItem.length; ++i) {

// Update visibility status
function updateStatus(statusText) {
  statusBox.innerHTML = statusText;
  statusBox.className = 'status status--' + visiblity;

// Milliseconds -> Seconds
function milliToSeconds(milli) {
  let seconds = ((milli % 60000) / 1000).toFixed(0);
  return seconds + ' secs';