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

              
                <div class="description">
  fixedpos tooltip + position-visibility: anchors-visible.
</div>
<div class="scroller">
  <div class="item">Item 0</div>
  <div class="item">Item 1</div>
  <div class="item" id="anchor">Item 2</div>
  <div class="item">Item 3</div>
  <div class="item">Item 4</div>
  <div class="item">Item 5</div>
  <div class="item">Item 6</div>
  <div class="item">Item 7</div>
  <div class="item">Item 8</div>
  <div class="item">Item 9</div>
  <div class="item">Item 10</div>
  <div id="anchor-top-anchor"></div>
  <div id="tooltip">The best item!</div>
</div>
              
            
!

CSS

              
                .description {
  font-family: 'Arial', sans-serif;
  font-size: small;
}

.scroller {
  position: relative;
  width: 300px;
  height: 150px;
  overflow-y: scroll;
  border: 2px solid #e0e0e0;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  background-color: #f8f8f8;
  font-family: 'Arial', sans-serif;
  font-size: large;
}

.item {
  padding: 10px;
  margin-top: 1px;
  background-color: #fff;
  color: #333;
  transition: background-color 0.2s ease;
}

.item:hover {
  background-color: #ffebc5;
}

#anchor {
  anchor-name: --anchor;
  background-color: orange;
}

/* Fake anchor at the top of the real anchor */
/* Used for showing the tooltip only when the top of the anchor is visible. */
#anchor-top-anchor {
  anchor-name: --anchor-top-anchor;
  position-anchor: --anchor;
  bottom: anchor(--anchor top);
  position: absolute;
  left: 0;
}

#tooltip {
  pointer-events: none;
  position: fixed;
  position-anchor: --anchor-top-anchor;
  position-visibility: anchors-visible;
  position-try-options: flip-block;
  bottom: anchor(--anchor-top-anchor top);

  padding: 10px;
  background-color: #333;
  color: #f0f0f0;
  text-align: center;
  border-radius: 4px;
  margin: 0 5px 5px 5px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  font-size: 14px;
  filter: drop-shadow(4px 4px 4px rgba(50,50,50,0.3));
}

#tooltip::after {
  content: " ";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: black transparent transparent transparent;
}

@supports not (position-visibility: anchors-visible) {
  #tooltip {
    display: none;
  }
}

body {
  padding: 5rem;
}
              
            
!

JS

              
                
              
            
!
999px

Console