Skip to content

Commit 5a997cd

Browse files
committed
Border playground 🛝
1 parent 651c8ad commit 5a997cd

File tree

2 files changed

+84
-21
lines changed

2 files changed

+84
-21
lines changed

14-border-playground/index.html

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,16 @@ <h1>Border Playground</h1>
6363
</fieldset>
6464
</div>
6565
<!-- 2 -->
66-
<div class="borderWidth">
67-
<p><strong>Border Color</strong></p>
66+
<div class="borderSize">
67+
<p><strong>Border Width</strong></p>
6868
<div class="slider">
6969
<input
7070
type="range"
7171
id="volume"
7272
name="volume"
7373
min="1"
7474
max="25"
75-
value="1"
75+
value="2"
7676
/>
7777
</div>
7878
</div>
@@ -109,6 +109,20 @@ <h1>Border Playground</h1>
109109
".radio input[type='radio']"
110110
); // Select all color radio buttons
111111

112+
const boxes = document.querySelectorAll(".box"); // Select all boxes
113+
const borderSize = document.querySelector(
114+
".borderSize input[type='range']"
115+
); // Select border size slider
116+
117+
const borderRadius = document.querySelector(
118+
".borderRadius input[type='range']"
119+
); // Select border radius slider
120+
121+
boxes.forEach((box) => {
122+
box.style.borderWidth = `${borderSize.value}px`;
123+
box.style.borderRadius = `${borderRadius.value}%`;
124+
});
125+
112126
colorRadioButtons.forEach((radioButton) => {
113127
const imaginaryCircle = radioButton.nextElementSibling; // Get imaginary circle
114128
const outerRing = imaginaryCircle.nextElementSibling; // Get outer ring circle
@@ -127,9 +141,23 @@ <h1>Border Playground</h1>
127141
imaginaryCircle.style.outline = "2px solid white"; // Imaginary circle white outline
128142
outerRing.style.outline = `2px solid ${selectedColor}`; // Outer circle colored outline
129143
outerRing.style.outlineOffset = "2px"; // Offset colored outline
144+
145+
boxes.forEach((box) => (box.style.borderColor = selectedColor));
130146
}
131147
});
132148
});
149+
150+
borderSize.addEventListener("change", (e) => {
151+
boxes.forEach((box) => {
152+
box.style.borderWidth = `${e.target.value}px`;
153+
});
154+
});
155+
156+
borderRadius.addEventListener("change", (e) => {
157+
boxes.forEach((box) => {
158+
box.style.borderRadius = `${e.target.value}%`;
159+
});
160+
});
133161
</script>
134162
</body>
135163
</html>

14-border-playground/style.css

Lines changed: 53 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,6 @@ main:last-child {
4242
justify-content: space-between;
4343
}
4444

45-
.boxes {
46-
display: grid;
47-
grid-template-columns: repeat(3, 1fr); /* Creates 3 equal columns */
48-
grid-template-rows: repeat(3, 1fr); /* Creates 3 equal rows */
49-
gap: 40px; /* Adds space between boxes (optional) */
50-
margin-top: 40px;
51-
}
52-
53-
.box {
54-
width: 200px;
55-
height: 200px;
56-
border: 1px solid red;
57-
display: flex;
58-
justify-content: center;
59-
align-items: center;
60-
font-weight: 600;
61-
}
62-
6345
p {
6446
font-size: 20px;
6547
}
@@ -152,3 +134,56 @@ input[type="radio"]:checked {
152134
.slider {
153135
margin-top: 20px;
154136
}
137+
138+
.boxes {
139+
display: grid;
140+
grid-template-columns: repeat(3, 1fr); /* Creates 3 equal columns */
141+
grid-template-rows: repeat(3, 1fr); /* Creates 3 equal rows */
142+
gap: 40px; /* Adds space between boxes (optional) */
143+
margin: 40px 0 0;
144+
}
145+
146+
.box {
147+
width: 200px;
148+
height: 200px;
149+
display: flex;
150+
justify-content: center;
151+
align-items: center;
152+
font-weight: 600;
153+
}
154+
155+
.one {
156+
border-style: solid;
157+
}
158+
159+
.two {
160+
border-style: dotted;
161+
}
162+
163+
.three {
164+
border-style: dashed;
165+
}
166+
167+
.four {
168+
border-style: double;
169+
}
170+
171+
.five {
172+
border-style: groove;
173+
}
174+
175+
.six {
176+
border-style: ridge;
177+
}
178+
179+
.seven {
180+
border-style: inset;
181+
}
182+
183+
.eight {
184+
border-style: outset;
185+
}
186+
187+
.nine {
188+
border-style: dashed solid;
189+
}

0 commit comments

Comments
 (0)