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 id="root">
  <div id="target"></div>

<div id="output">intersectionRatio: <pre></pre></div>


                html {
  box-sizing: border-box;
  font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
*, *:before, *:after {
  box-sizing: inherit;
body {
  background-color: #1d1e22;
  margin: 0;
  padding: 0;

#root {
  align-items: center;
  background-color: #FFF;
  border: 3px solid rebeccapurple;
  display: flex;
  height: 400px;
  justify-content: center;
  margin: 20px auto;
  overflow: hidden;
  position: relative;
  width: 400px;

#target {
  animation: sidetoside 5s linear infinite alternate;
  background-color: rebeccapurple;
  background-image: radial-gradient(ellipse at center, #ffffff 0%,#ffffff 14%,#663399 15%,#663399 34%,#ffffff 35%,#ffffff 50%,#663399 51%,#663399 99%);
  background-position: center;
  background-repeat: no-repeat;
  height: 300px;
  pointer-events: none;
  transition: 0.5s;
  width: 300px;
@keyframes sidetoside {
  0% {
    transform: translate3d(-400px, 0, 0);
  100% {
    transform: translate3d(400px, 0, 0);

#output {
  color: #FFF;
  margin: 20px auto;
  width: 400px;
#output pre {
  display: inline;
  font-size: 16px;
  padding: 0 10px;


                const root = document.querySelector('#root');
const target = document.querySelector('#target');
const output = document.querySelector('#output pre');
const io_options = {
  root: root,
  rootMargin: '0px',
  threshold: [...Array(100).keys()].map(x => x / 100)
let io_observer;

function io_callback (entries) {
  output.innerText = entries[0].intersectionRatio;

io_observer = new IntersectionObserver(io_callback, io_options);