cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

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.

  <div id="frame">
    <div class="window"></div>
    <p class="label"></p>

    <div class="window"></div>
    <p class="label"></p>

    <div class="window"></div>
    <p class="label"></p>

    <div class="window"></div>
    <p class="label"></p>
              #frame { width: 500px; text-align: center; margin: 50px 10px; }
section { display: inline-block; border: 1px solid black; margin: 10px 20px; }
.window { width: 200px; height: 150px; background-color: cyan; }

  /*** init variables ***/

  // just a bucket of things
  var things = [
    { module: 'sky', label: 'the sky' },
    { module: 'bells', label: 'a bell' },
    { module: 'bilboquet', label: 'a bilboquet' },
    { module: 'apple', label: 'an apple' },
    { module: 'hat', label: 'a hat'},
    { module: 'javascript', label: 'a javascript' },
    { module: 'sign', label: 'the sign' },
    { module: 'rooster', label: 'a rooster' }

  var $sections = $('section');

  // keep track of each window/label used
  var usedGoods = [];

  /*** helper functions ***/

  // returns id of object not yet used
  var generateRandomThing = function() {

    var usableId;
    var need = true;

    while ( need ) {
      usableId = Math.floor(Math.random() * things.length);

      // if x is not in usedGoods, set need to false and set as used
      if ( usedGoods.indexOf(usableId) === -1 ) {
        need = false;

    return usableId;

  /*** let's generate some friggin art ***/

  // for each section
    // generate random window and label to use
    var windowId = generateRandomThing();
    var labelId = generateRandomThing();

    // set component for this section's window (right now it just shows value of module property)
    $(this).find('.window').text( things[windowId].module);

    // set text for this section's window
    $(this).find('.label').text( things[labelId].label);


🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................