I am trying to do a little exercise that refreshes the page when I click the big button in the middle, and the small dots change color. I stopped scrolling the page, so the page is filled with dots, but I noticed that the overflow property works differently in different browsers. Then I thought about another problem, on mobile phones or tablets, the dots will be displayed differently again! Therefore, I am not sure that this is even possible, but the desired result is that the loop creates points until the screen is full and the button is displayed in the middle of the screen. Can someone please tell me if this idea is possible, since I could not find such questions. Or, if there is a better way to get the desired result. Also, if you have time, please briefly explain why, because I want to understandhow it works and learn from it. So ... This is JavaScript
var htmlDot = "";
var red;
var green;
var blue;
var rgbColor;
function colourSelect() {
return Math.floor(Math.random() * 256 );
}
for(var i = 1; i<=100; i+=1) {
red = colourSelect();
green = colourSelect();
blue = colourSelect();
rgbColor = "rgb(" + red + "," + green + "," + blue + ")";
htmlDot += "<div style=\"background-color:"+ rgbColor + " \"></div>";
}
document.write(htmlDot);
HTML
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="main.css">
</head>
<body>
<button id="refresh">Click Me!</button>
<script src="script.js"></script>
</body>
</html>
CSS
body {
position: relative;
overflow: hidden;
}
#refresh {
font: 40px bold;
font-family: sans-serif;
width: 200px;
height: 200px;
display: inline-block;
border-radius: 50%;
margin: 5px;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: auto;
background-color: rgb();
}
div {
width: 50px;
height: 50px;
display: inline-block;
border-radius: 50%;
margin: 5px;
}