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.


                <!-- Learn about this code on MDN: -->

<section class="global_wrapper">
  <main><h2>Main Contents</h2></main>
  <aside class="sidebar">
    <h2>Sidebar Contents</h2>
    <p> scroll down↓</p>
  <div class="sampleBox">
    <div class="label topLeft"></div>
    <div class="label topRight"></div>
    <div class="label bottomLeft"></div>
    <div class="label bottomRight"></div>
    <div class="mark top">trigger→</div>
        <div class="mark second">trigger→</div>
        <div class="mark middle">trigger→</div>
            <div class="mark fourth">trigger→</div>
        <div class="mark bottom">trigger→</div>



                .contents {
  position: absolute;
  width: 700px;
  height: 1725px;

  display: flex;
  max-width: 100%;
  background: #c1c1c1;
  flex-basis: 60%;
  border: gray 5px solid;
  flex-basis: 40%;
  border: gray 5px solid;
  height: 300px;
  overflow: scroll;

  color: red;
  font-size: 1.3em;
  position: absolute;
  top: 0%;
  left: -80px;
  transform: translateY(-50%);
  top: 25%
  top: 50%
  top: 75%
  top: 100%
.sampleBox {
  position: relative;
  width: 300px;
  background-color: rgb(245, 170, 140);
  border: 2px solid rgb(201, 126, 17);
  padding: 4px;
  margin: 250px 100px;
  height: 200px;

.label {
  font: 14px "Open Sans", "Arial", sans-serif;
  position: absolute;
  margin: 0;
  background-color: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(0, 0, 0, 0.7);
  width: 3em;
  height: 18px;
  padding: 2px;
  text-align: center;

.topLeft {
  left: 2px;
  top: 2px;

.topRight {
  right: 2px;
  top: 2px;

.bottomLeft {
  bottom: 2px;
  left: 2px;

.bottomRight {
  bottom: 2px;
  right: 2px;





function startup() {
  let sidebar = document.querySelector("aside");

  // Options for the observers

  const option = {
    root: sidebar,
    rootMargin: "0px",
    threshold: [0, 0.25, 0.5, 0.75, 1]
    let observer = new IntersectionObserver(intersectionCallback, option);

function intersectionCallback(entries) {
  entries.forEach(function(entry) {
    let box =;
    let visiblePct = (Math.floor(entry.intersectionRatio * 100)) + "%";

    box.querySelector(".topLeft").innerHTML = visiblePct;
    box.querySelector(".topRight").innerHTML = visiblePct;
    box.querySelector(".bottomLeft").innerHTML = visiblePct;
    box.querySelector(".bottomRight").innerHTML = visiblePct;