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.


                <button id="escape-button">Click here</button>


                #escape-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 1em 2em;
  font-size: 20px;
  background-color: #7e2cdb;
  color: white;
  border: none;
  border-radius: 6px;
  font-family: 'IBM Plex Sans';
  box-sizing: border-box;



                var button = document.getElementById("escape-button");
var proximity = 300;
var isButtonMoving = false;

function moveButton() {
  if (isButtonMoving) {

  var viewportWidth = window.innerWidth;
  var viewportHeight = window.innerHeight;
  var buttonWidth = button.offsetWidth;
  var buttonHeight = button.offsetHeight;

  var currentX = parseInt( || 0;
  var currentY = parseInt( || 0;

  var randomX, randomY;
  var minDistance = proximity + 50;

  do {
    randomX = Math.floor(Math.random() * (viewportWidth - buttonWidth));
    randomY = Math.floor(Math.random() * (viewportHeight - buttonHeight));
  } while (calculateDistance(currentX, currentY, randomX, randomY) < minDistance);

  if (randomX + buttonWidth > viewportWidth) {
    randomX = viewportWidth - buttonWidth;
  if (randomY + buttonHeight > viewportHeight) {
    randomY = viewportHeight - buttonHeight;
  } = "left 0.5s, top 0.5s"; = randomX + "px"; = randomY + "px";

  isButtonMoving = true;

  button.addEventListener("transitionend", function() {
    isButtonMoving = false;
  }, { once: true });

function calculateDistance(mouseX, mouseY, buttonX, buttonY) {
  var dx = mouseX - buttonX;
  var dy = mouseY - buttonY;
  return Math.sqrt(dx * dx + dy * dy);

function updateButtonText() {
  var texts = [
    "Catch me",
    "C'mon, CLICK",
    "I can do this forever",
    "You're so close!",
    "CLICK ON ME",
    "Oh for God's sake",
    "Massive L",
    "Are you just bored?",
    "Just click...",
    "You do this everyday",
    "How hard can it be?",
    "I'm right HERE",
    "Click to WIN!!!",
    "Skill issue...",
    "Game Over bro",
    "Catch me if you can",
    "It's just a button...",
    "I can't help you",
    "OVER HERE",
    "Click me, it's FREE!",
    "WHAT are you doing?",
    "OMG 😂",
  var randomText = texts[Math.floor(Math.random() * texts.length)];
  button.innerHTML = randomText;

document.addEventListener("mousemove", function(event) {
  var mouseX = event.clientX;
  var mouseY = event.clientY;
  var buttonRect = button.getBoundingClientRect();
  var buttonX = buttonRect.left + button.offsetWidth / 2;
  var buttonY = + button.offsetHeight / 2;
  var distance = calculateDistance(mouseX, mouseY, buttonX, buttonY);

  if (distance < proximity) {