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

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.

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

              
                <div id="pixelboard"></div>
<p class="message">REBUILD THE ALIEN<span>DRAG AND SWAP BY SORTABLE.JS</span></p>
              
            
!

CSS

              
                body {
  background-color: #000;
  display: grid;
  justify-content: center;
  margin-top: 40px;
}

#pixelboard {
  display: grid;
  grid-template-columns: 20px 20px 20px 20px 20px 20px 20px 20px 20px 20px 20px 20px 20px 20px 20px;
  grid-template-rows: 20px 20px 20px 20px 20px 20px 20px 20px 20px 20px 20px 20px 20px 20px 20px;
  grid-gap: 1px;
  width: fit-content;
}

.rect {
  border-radius: 1px;
  opacity: 0;
  background-color: #010;
  height: 20px;
  width: 20px;
}

.message {
  color: #009900;
  font-size: 1.6em;
  font-family: "Coda", cursive;
  opacity: 0;
  text-align: center;
}

.message span {
  display: block;
  font-size: 0.4em;
}

              
            
!

JS

              
                const alien = [
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,
0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,
0,0,0,1,1,0,0,1,0,0,1,1,0,0,0,
0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,
0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,
0,0,0,1,0,1,0,1,0,1,0,1,0,0,0,
0,0,0,0,1,0,1,0,1,0,1,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,
];

// Create pixelboard
for (i = 0; i <= 224; i++) {
  const node = document.createElement("div");
  node.setAttribute("id", "pix" + i);
  node.setAttribute("class", "rect");
  document.getElementById("pixelboard").appendChild(node);
}

// Add Alien
for (var i = 1; i < 225; i += 1) {
  var pixelart = document.getElementById(i);
  if (alien[i] == 1) {
      var element = document.getElementById("pix" + i);
     element.style.backgroundColor = "#00cc00";
  }
}

// Show Alien and text
gsap.to("#pixelboard div", {duration: 1, opacity:1, stagger: 0.01});
gsap.to(".message", {duration:5 ,delay:2, opacity:1});

// Rebuild (Sortable.js)
new Sortable(pixelboard, {
    	swap: true, 
      animation: 100
});
              
            
!
999px

Console