Skip to content

Commit

Permalink
Shrink board; Randomize nums; Refine css
Browse files Browse the repository at this point in the history
  • Loading branch information
andHW committed Feb 1, 2024
1 parent 605f2e2 commit b0767d8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
14 changes: 6 additions & 8 deletions main.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ body {

#screen {
display: grid;
grid-template-columns: repeat(8, 1fr);
grid-template-columns: repeat(7, 1fr);
transform: rotate(-45deg);
}

.square {
display: flex;
justify-content: center;
align-items: center;
width: 60px;
height: 60px;
background-color: white;
Expand Down Expand Up @@ -52,12 +55,7 @@ body {
color: cyan;
opacity: 0.6;
text-shadow: 0 0 2px #000;
transform: rotate(45deg);
font-size: 1.5em;
/* TODO: Need a better way to center the text... */
text-align: center;
position: relative;
bottom: 25px;
right: 18px;
user-select: none;
position: absolute;
transform: rotate(45deg) translateY(100%);
}
12 changes: 10 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
const N = 7 * 7;
let nums = Array.from({ length: N }, (_, i) => i + 1);
for (let i = 0; i < N; i++) {
let j = Math.floor(Math.random() * N);
[nums[i], nums[j]] = [nums[j], nums[i]];
}


document.addEventListener("DOMContentLoaded", function () {
let screen = document.getElementById("screen");

for (let i = 0; i < 64; i++) {
for (let i = 0; i < 7 * 7; i++) {
let squareDiv = document.createElement("div");
squareDiv.classList.add("square");

Expand All @@ -10,7 +18,7 @@ document.addEventListener("DOMContentLoaded", function () {

let textDiv = document.createElement("div");
textDiv.classList.add("text");
textDiv.textContent = i;
textDiv.textContent = nums[i];

squareDiv.appendChild(picDiv);
squareDiv.appendChild(textDiv);
Expand Down

0 comments on commit b0767d8

Please sign in to comment.