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 class="container"></div>


                .container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  user-select: none;
  pointer-events: none;
img {
  position: absolute;


                // Array with all our images
var allImages = [
// The counter
var count = 0
// Wait for the DOM to be loaded
document.addEventListener("DOMContentLoaded", function () {
  // Select the container
  var container = document.querySelector('.container')
  // Generate a random number
  var randomNumber = function() {
    return Math.floor(Math.random() * (allImages.length));
  // Place the image generated by loadImage function
  var placeImage = function(x, y, newImage) {
    // Wait for the image to be loaded
    newImage.addEventListener("load", function() {
      // Put the new image into the DOM
      // Select the new image by his id attribute
      var theImage = document.querySelector('[id="' + count + '"]')
      // Center the image on mouse pointer = x - (theImage.width/2) + 'px' = y - (theImage.height/2) + 'px'
      // Increment the counter
  // Create a new image
  var loadImage = function(x, y) {
    var newImage = new Image()
    // Set the source
    newImage.src = allImages[randomNumber()]
    // Set the attribute Id
    newImage.setAttribute('id', count)
    // Place it
    placeImage(x, y, newImage)
  // Listen to the mouseup event                             
  document.addEventListener('click', function (event) {
    // Get the mouse position
    var x = event.clientX
    var y = event.clientY
    // load image
    loadImage(x, y)
  }, false);