You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
479 B
18 lines
479 B
4 years ago
|
const boxesContainer = document.getElementById('boxes')
|
||
|
const btn = document.getElementById('btn')
|
||
|
|
||
|
btn.addEventListener('click', () => boxesContainer.classList.toggle('big'))
|
||
|
|
||
|
function createBoxes() {
|
||
|
for (let i = 0; i < 4; i++) {
|
||
|
for (let j = 0; j < 4; j++) {
|
||
|
const box = document.createElement('div')
|
||
|
box.classList.add('box')
|
||
|
box.style.backgroundPosition = `${-j * 125}px ${-i * 125}px`
|
||
|
boxesContainer.appendChild(box)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
createBoxes()
|