Skip to content

Commit f55ae65

Browse files
committed
done 6
1 parent 1f97348 commit f55ae65

File tree

3 files changed

+66
-6
lines changed

3 files changed

+66
-6
lines changed

6project/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# 3D Boxes Grid with Numbers
2+
3+
###### Summary for this project
4+
###### Purpose: Showcase JavaScript code manages a to-do list.
5+
6+
**Link to work:** [3D Boxes Grid with Numbers](https://arduino731.github.io/JavaScript-Algorithms-and-Data-Structures/6project/)
7+
8+
This project demonstrates key JavaScript concepts by creating an interactive 4x4 grid of boxes with animated styles and numbered overlays. A button allows toggling transformations (like a 3D flip effect), and each box is paired with a number, which updates its style dynamically.
9+
10+
🧠 Key Concepts & Learning Outcomes
11+
📦 DOM Manipulation
12+
Use of document.createElement() to dynamically generate HTML elements.
13+
14+
Manipulating classes via classList.add() and classList.toggle() to apply styles and transitions.
15+
16+
Appending elements (appendChild) to parent containers efficiently.
17+
18+
🧮 Algorithms / Logic
19+
Nested for loops (i, j) simulate a 2D grid (matrix-like layout).
20+
21+
Calculating box numbers via simple formula: outputNumber = i * 4 + j + 1 (demonstrates how indexing works).
22+
23+
Mapping positions using backgroundPosition for image cropping or sprite sheet logic.
24+
25+
🧱 Data Structures
26+
Though basic, this project conceptually uses a 2D array pattern (i, j looping) to represent grid data.
27+
28+
Encourages thinking in terms of layout structures and coordinate mapping.
29+
30+
🎨 CSS & Styling
31+
Flexbox is used for layout: .boxes and .boxes2 allow wrapping elements in rows and columns.
32+
33+
Transitions and transformations (transform: rotateY, rotateZ) offer interactive 3D effects.
34+
35+
Responsive changes are toggled via class changes (.big, .big2), simulating animation states.
36+
37+
🚀 Interactivity
38+
Button click toggles transformations and scaling of both background (#boxes) and numbers (#numbers), showcasing basic event-driven programming.
39+
40+
Visually dynamic feedback teaches how styles and logic can work together.
41+
42+
✅ What You Built
43+
A 4x4 dynamic grid that can rotate and scale.
44+
45+
Numbered overlay blocks that move in sync with background images.
46+
47+
A modular, reusable way of thinking about grid-based interfaces.

6project/script.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ const boxesContainer = document.getElementById('boxes')
22
const numberContainer = document.getElementById('numbers')
33
const btn = document.getElementById('btn')
44

5-
btn.addEventListener("click", ()=> boxesContainer.classList.toggle('big'))
5+
btn.addEventListener("click", ()=>{
6+
boxesContainer.classList.toggle('big');
7+
numbersContainer.classList.toggle('big2');
8+
})
9+
610

711
function createBoxes(){
812
for(let i=0; i<4; i++){
@@ -16,10 +20,9 @@ function createBoxes(){
1620
number.textContent = outputNumber;
1721

1822
box.style.backgroundPosition = `${-j * 125}px ${-i * 125}px`
19-
number.style.backgroundPosition = `${-j * 125}px ${-i * 125}px`
2023

24+
box.appendChild(number)
2125
boxesContainer.appendChild(box)
22-
numberContainer.appendChild(number)
2326
}
2427
}
2528
}

6project/style.css

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,25 @@ body {
9999
.boxes.big .box {
100100
transform: rotateZ(360deg);
101101
}
102-
.box::after , .box2:after{
102+
/* .box::after , .box2:after{
103103
content: '';
104-
/* background-color: #f6e58d; */
104+
background-color: #f6e58d;
105105
position: absolute;
106106
top: 8px;
107107
right: -15px;
108108
height: 100%;
109109
width: 15px;
110110
transform: skewY(45deg);
111-
}
111+
} */
112112

113+
/* .box::before {
114+
content: '';
115+
background-color: #f9ca24;
116+
position: absolute;
117+
bottom: -15px;
118+
left: 8px;
119+
height: 15px;
120+
width: 100%;
121+
transform: skewX(45deg);
122+
} */
113123

0 commit comments

Comments
 (0)