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

              
                <span class="filled-text">
  MOVE THE CIRCLE OVER THIS TEXT.<br>
  MOVE THE CIRCLE OVER THIS TEXT.<br>
  MOVE THE CIRCLE OVER THIS TEXT.<br>
  MOVE THE CIRCLE OVER THIS TEXT.<br>
</span>
<span class="outlined-text" aria-hidden="true">
  MOVE THE CIRCLE OVER THIS TEXT.<br>
  MOVE THE CIRCLE OVER THIS TEXT.<br>
  MOVE THE CIRCLE OVER THIS TEXT.<br>
  MOVE THE CIRCLE OVER THIS TEXT.<br>
</span>
<div id="circle"></div>
              
            
!

CSS

              
                $text-color: #fff;
$bg-color: #3590f3;
$circle-color: $bg-color;
$circle-size: 200px;

* {
  ::selection {
    background: none;
  }
  font-family: sans-serif;
  letter-spacing: -5px;
  cursor: grabbing;
  margin: 0;
  box-sizing: border-box;
  position: absolute;
}
body {
  background: $bg-color;
  overflow: hidden;
  height: 100vh;
}
span {
  width: 100vw;
  padding: 5rem;
  font-size: 5rem;
  font-weight: bold;
  line-height: 4rem;
  text-align: center;
  top: 50vh;
  left: 50vw;
  transform: translate(-50%, -50%);
  @media screen and (max-width: 768px) {
    padding: 5px;
    font-size: 3rem;
    line-height: 2.5rem;
  }
  &.filled-text {
    color: $text-color;
    z-index: 0;
  }
  &.outlined-text {
    color: transparent;
    -webkit-text-stroke: 0.5px $text-color;
    z-index: 2;
  }
}

#circle {
  height: $circle-size;
  width: $circle-size;
  border-radius: 50%;
  background: $circle-color;
  border: 20px solid $text-color;
  box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
  top: calc(50vh - 100px);
  left: calc(50vw - 100px);
}

              
            
!

JS

              
                console.log(
  "This pen uses z-index, color, and shadow to create an x-ray illusion. The elements in order from back to front are: solid text, circle, outlined text. The circle's background color must be the same as the body's. The circle's border, the solid text color, and the text outline must also all be the same color. When the circle passes between the solid and outlined text it covers the solid text, leaving only the outline visible."
);

//this function keeps the circle tracked to mouse movement by moving it every time the cursor moves
document.addEventListener("mousemove", (e) => {
  // create variables for circle element and 50% of circle diameter:
  const circle = document.getElementById("circle");
  const halfCircleSize = circle.offsetHeight / 2;

  //get cursor location:
  const mouse_x = e.clientX;
  const mouse_y = e.clientY;

  // move the circle to the cursor's location and offset the circle by 50% of its diameter so that it is always centered with the cursor:
  circle.style.left = `${mouse_x - halfCircleSize}px`;
  circle.style.top = `${mouse_y - halfCircleSize}px`;
});

              
            
!
999px

Console