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

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.

HTML

              
                <html>
<head>
    <title>Pixel Art Maker!</title>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Press+Start+2P">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Bungee+Shade">
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <h1>@drcpmcg's</h1>
    <h2>Pixel Canvas</h2>

    <div class = "settings">
    <h3><strong>INSTRUCTIONS</strong></h3>
    <h3>1. Choose Grid Size</h3>
      <form id="sizePicker">
          Grid Height:
          <input type="number" id="inputHeight" name="height" min="1" max="50" value="1">
          Grid Width:
          <input type="number" id="inputWeight" name="width" min="1" max="50" value="1">
          <input type="submit" value="create canvas">
          <p>(To clear the grid, press "create canvas" button again.)</p>
      </form>

      <h3>2. Pick a Color</h3>
      <input type="color" id="colorPicker">
      <p>(On Mac OS, re-select a custom color with the "eyedropper" tool in the color picker.)</p>
      <p>(On Windows, use the "Add to Custom Colors" button to enable re-selection.)</p>
      <h3>3. Click Pixels to Build Designs!</h3>
      <p>(To erase a pixel, double click on it.)</p>
    </div>
    <div class = "canvas">
      <table id="pixelCanvas"></table>
    </div>
    <script
			  src="https://code.jquery.com/jquery-3.3.1.min.js"
			  integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
			  crossorigin="anonymous"></script>
    <script src="designs.js"></script>
</body>
</html>

              
            
!

CSS

              
                body {
    text-align: center;
    background-image:
    url('https://static.pexels.com/photos/100864/pexels-photo-100864.jpeg');
    /* Photo by Saulo Zayas from Pexels https://www.pexels.com/photo/35mm-film-grain-texture-100864/ */
    background-color: none;
}

h1 {
    text-align: center;
    font-family: "Bungee Shade";
    font-size: 50px;
    margin: 0.2em;
}

h2 {
    text-align: center;
    font-family: "Press Start 2P" ;
    font-size: 64px;
    margin: 0.2em;
    background: linear-gradient(90deg,#ff0000 0%, #0031ff 80%);
}

.canvas {
    padding: 20px;

}

.settings {
  
    box-sizing: border-box;
    text-align: center;
    display: inline-block;
    border: 10px ridge #000000;
    padding: 10px;
    background: #ffffff;
    box-shadow: 10px 10px 16px 7px rgba(0,0,0,0.75);
}

h3 {
    margin: 1em 0 0.25em;
}

h3:first-of-type {
    margin-top: 0.5em;
}

table,
tr,
td {
    border: 1px solid black;
    background-color: white;
}

table {
    border-collapse: collapse;
    margin: 0 auto;
}

tr {
    height: 20px;
}

td {
    width: 20px;
    background-color: white;
}

input[type=number] {
    width: 6em;
}

              
            
!

JS

              
                var canvas = $("#pixelCanvas");


function makeGrid() {
  var row = $("#inputHeight").val();
  var col = $("#inputWeight").val();
  canvas.find("*").remove();
  for (var x = 0; x < row ; x++){
    canvas.append("<tr></tr>");
    for (var y = 0 ; y < col ; y++){
      canvas.children().last().append("<td></td>");
    }
  }
}

canvas.on("click", "td", function(){
  var color = $("#colorPicker").val();
    $(this).css("background-color", color);
})

canvas.on("dblclick", "td", function(){
  $(this).css("background-color", "white");
})

$("#sizePicker").on("submit", function(event){
  event.preventDefault();
  makeGrid();
})

              
            
!
999px

Console