Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

134
Vistas
Creating a Etch-a-Sketch grid with JavaScript

I am creating a grid for an Etch-a-Sketch project. I have an empty div (.container) in my HTML and use a JS loop to create a 16x16 grid. All appended elements appear in the inspect tool, but not on Live screen. You'll see my code below, thanks!

HTML:

<!DOCTYPE html>
<html lang="en-US">
 
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Etch and Sketch</title>
    <link rel="stylesheet" href="style.css">
</head>


<body>
    <h1 class="title">Etch a Sketch</h1>
    <div class="gridSize">Waiting</div>
    <div class="buttons">
        <button class="clear">Clear</button>
        <button class="black">Black</button>
        <button class="colors">Colors</button>
        <div class="colorPalette">Color Palette</div>
     </div>

     <div class="container">
    </div>

     <script src="script.js"></script>
</body> 
</html>

Javascript:

const container = document.querySelector(".container");

let gridSize = 16;

function makeGrid(screenSize) {
  for (let i = 0; i < screenSize ** 2; i++) {
      let square = document.createElement("div");
      square.classList.add('square');
      square.style.backgroundColor = 'blue';
      container.appendChild(square);
  }
  container.style.gridTemplateColumns = 'repeat(16, auto)';
  container.style.gridTemplateRows = 'repeat(16, auto)';
};

makeGrid(gridSize);

CSS:

.container {
  border-color: 1px solid black;
  background-color: blue;
  display: grid;
  width:50%;
  height:50%;
}

.square {
  border-color: 1px solid black;
  background-color: blue;
}
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda