Pen Settings

HTML

CSS

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

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

              
                <!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  </head>
  <body>
  <div id="container">
   
    <br />
    </div>
 <div id="Btns">
      <button id="recreate" onclick="resizeGrid(this.value)">remake grid</button>
      </div>
  <script src="script.js"></script>
</body>
</html>

              
            
!

CSS

              
                /*
added the container that holds the grid to manipulate the css.
made it appear more like the etch-a-sketch board.

width: 25.25%;
*/


#container {
  
  width: 50%;
  height: 50%;
  margin-top:50px;
  margin-left: auto;
  margin-right: auto;
  background: "white";
  overflow:hidden;
  box-sizing: border-box;
}

/*

there is a bit of extra space being generated on the right side of the grid.
row seems to be causing the issue will need to review.
Checked the grid creation which seems to be fine.
*/
.row{
 line-height: 0;
  
}

.row:first-child .box {
    border-top: 1px solid red; 
}

.box{
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 1px solid red;
 
  box-sizing: border-box;
  margin: 0;
}

.box: first-child{
  border-left: 1px solid red;
}

              
            
!

JS

              
                //try flexbox
/*
adding a button and having the submit grab the value for the backend function

*/
//trying to make a function for creating divs
window.onload = function(){
  var createGrid = prompt("How many rows do you want?");
  console.log(createGrid);
  for(i = 0; i < createGrid; i++){
    var row = document.createElement('div');
      row.className = "row";
      row.id = "row" + i;
    
  for(k= 0; k < createGrid; k++ ){
    var box = document.createElement('div');
      box.className = "box";
      row.appendChild(box);
    }
       container.appendChild(row);
  }
        return container;
}

//create a grid
//generates a grid with the original div container already on index.html you need to start messing with the code you work with to gain a better understanding of what it's doing
function grid() {
  var container = document.getElementById("container");
        for (i = 0; i <= 16; i++){
           
        
          
    
     for(k = 0; k <= 16; k ++){
          var box = document.createElement("div");
           box.className = "box";
         //    row.appendChild(box);
         
          }
           container.appendChild(row);
          }
           return container;
        }
         // grid(document.body);
            



function resizeGrid(){
  clearGrid();
  //missing a clear grid function!
}
  
  //right now the resizing is adding to the bottom of the old grid.
  function clearGrid(){
    
  }
  
  
document.addEventListener("mouseover",(e)=>{
  if(!e.target.classList.contains("box")){
      return;
  }
  e.target.style.background = "#3d3d3d";
})
              
            
!
999px

Console