cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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="module">
  <pre class="javascript"><code>$(function(){

  /*** init variables ***/

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

  var $sections = $('section');

  // keep track of each window/label used
  var usedGoods = [];
  var randomCorrectWindowId = Math.floor(Math.random() * 4);

  /*** 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;

    // if random correct window, label and window IDs are the same
    if ( i === randomCorrectWindowId ) {
      labelId = windowId;
    else {
      labelId = generateRandomThing();

    // embed iframe of corresponding module
    var $iframe = $('&lt;iframe>');
      'src': 'http://vart.institute/magritte/modules/'+ things[windowId].module+'.html',
      'scrolling': 'no'

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

              body { margin: 0; padding: 0; color: lime; background: black; }
#module { width: 100%; height: 200px; position: relative; overflow: hidden; }

@-webkit-keyframes javascript {
	0% {margin-top: 0px;}
	100% {margin-top: -800px;}
@-moz-keyframes javascript {
	0% {margin-top: 0px;}
	100% {margin-top: -800px;}

.javascript { position: absolute; 
  -webkit-animation: javascript 15s linear infinite; 
  -moz-animation:  javascript 15s linear infinite; 
  animation: javascript 15s linear infinite;

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.


Loading ..................