Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

86
Views
cómo hacer que la cuadrícula sea del mismo tamaño

Creé un botón de entrada que agregará más cuadrados a la cuadrícula, pero necesito que la cuadrícula tenga el mismo tamaño, independientemente de cuántos cuadrados le agregue, mientras que los cuadrados se vuelven más pequeños para tener en cuenta dentro de la cuadrícula.

 const grid = document.querySelector('.grid'); const blackButton = document.querySelector('.blackbutton'); blackButton.addEventListener('click', blkButton); const clear = document.querySelector('.clearbutton') clear.addEventListener('click', clearGrid); const eraserButton = document.querySelector('.eraserbutton') eraserButton.addEventListener('click', ersButton) const rainbowButton =document.querySelector('.rainbowbutton') rainbowButton.addEventListener('click', rbwButton) //DOM handling function getGrid(size) { const grid = document.querySelector('.grid'); const boxs = grid.querySelectorAll(".box"); boxs.forEach((div) => div.remove()); grid.style.gridTemplateColumns = `repeat( ${size} , 1fr)`; grid.style.gridTemplateRows = `repeat( ${size} , 1fr)`; let amount = size * size for (let i = 0; i < amount; i++) { const box = document.createElement('div'); box.classList.add('box'); grid.appendChild(box); } } getGrid(16) function changeSize(input){ if (input >= 2 && input <= 100) { getGrid(input); } else { console.log("Only between 2 to 100 Fam!") } }
about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!