Skip to content
Advertisement

how do I fix the total amount of pixel used from a grid in css?

I’m sorry if this is a repeated question and I’d like some help cause I’m a noob. I created a grid. But every time I enter a different number, it uses a different total amount of pixel. I want the height and the width of the body that contains grid to stay exactly the same size no matter what the number of grid is.

https://moonsol124.github.io/ETCH-A-SKETCH-TOP-PROJECT-/

here is what I made.

java:

JavaScript

}

css:

JavaScript

html:

JavaScript

please tell me if my approach is wrong. thanks for your help.

Advertisement

Answer

I think this will help to you solve your problem I just add these parts

JavaScript

it access the parent alement and create div inside that element

And you can pass any number here to test onLoad=”createGrid(6)”

JavaScript
JavaScript
JavaScript
Advertisement