Skip to content

Commit

Permalink
second v
Browse files Browse the repository at this point in the history
  • Loading branch information
matiev committed Apr 11, 2022
0 parents commit 03da89f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const box = document.querySelectorAll('.box');
window.addEventListener('DOMContentLoaded', ch);
let arr = [];
function ch() {
for (let b of box) {
for (let i=0; i<3; i++) {
arr.push(Math.floor(Math.random() * 255));
}
arr = arr.join(' ');
b.style.backgroundColor = `rgb(${arr})`;
arr = [];
}
}
22 changes: 22 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>js-random-color-rgb</title>
</head>
<body>
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
<div class="box">5</div>
<div class="box">6</div>
<div class="box">7</div>
<div class="box">8</div>
<div class="box">9</div>
<script src="app.js"></script>
</body>
</html>
8 changes: 8 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.box {
display: flex;
flex-wrap: wrap;
width: 40px;
height: 30px;
margin: 10px;
border: 1px solid blue;
}

0 comments on commit 03da89f

Please sign in to comment.