-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
286 lines (250 loc) · 7.12 KB
/
index.html
File metadata and controls
286 lines (250 loc) · 7.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="BoxCraft helps beginners learn and visualize CSS sizing, box model, and layout with interactive tools.">
<meta name="keywords" content="CSS, sizing, box model, visual, web development, beginners, responsive">
<meta name="author" content="Mohammed Owais">
<title>BoxCraft – Learn CSS Sizing Visually</title>
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: 'Segoe UI', sans-serif;
background: linear-gradient(to right, #0f2027, #203a43, #2c5364);
color: #fff;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
padding: 30px 15px;
min-height: 100vh;
animation: fadeIn 1s ease-in;
position: relative;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
h2 {
font-size: 2rem;
margin-bottom: 20px;
text-align: center;
}
/* Background Grid */
.grid {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
background-size: 20px 20px;
background-image: linear-gradient(to right, #444 1px, transparent 1px),
linear-gradient(to bottom, #444 1px, transparent 1px);
z-index: 0;
}
/* ✅ Centered Resizable Box */
#box {
width: 200px;
height: 200px;
border: 2px dashed #00ff99;
resize: both;
overflow: auto;
background-color: #111;
margin-top: 20px;
z-index: 1;
transition: width 0.2s ease, height 0.2s ease;
min-width: 20px !important;
min-height: 20px !important;
max-width: none !important;
max-height: none !important;
}
#dimensions {
margin-top: 15px;
font-size: 18px;
color: #00ff99;
}
select, input[type="range"], button {
margin: 8px;
padding: 8px 12px;
background: #333;
color: white;
border: 1px solid #555;
border-radius: 6px;
font-size: 14px;
transition: background 0.3s;
}
button:hover {
background: #00ff99;
color: #000;
cursor: pointer;
}
#exportedCode {
margin-top: 15px;
white-space: pre-wrap;
background: #222;
padding: 15px;
border-radius: 8px;
width: 100%;
max-width: 700px;
font-family: monospace;
border-left: 4px solid #00ff99;
}
.controls {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
gap: 10px;
margin-top: 20px;
}
label {
margin-right: 6px;
font-size: 14px;
}
/* ⭐ About Section */
.about {
margin-top: 50px;
padding: 30px;
max-width: 700px;
background: rgba(255, 255, 255, 0.05);
border-radius: 16px;
text-align: center;
box-shadow: 0 4px 15px rgba(0,0,0,0.3);
animation: fadeIn 1s ease-in;
position: relative;
z-index: 2;
}
.about h2 {
margin-bottom: 15px;
font-size: 1.8rem;
color: #00ff99;
}
.about p {
margin-bottom: 20px;
line-height: 1.6;
font-size: 16px;
}
/* Beautiful Animated Button */
.btn {
display: inline-block;
padding: 12px 24px;
font-size: 16px;
font-weight: bold;
text-decoration: none;
border-radius: 30px;
background: linear-gradient(135deg, #00ff99, #00ccff);
color: #000;
box-shadow: 0 4px 12px rgba(0, 255, 153, 0.4);
transition: transform 0.2s ease, box-shadow 0.3s ease, background 0.3s ease;
}
.btn:hover {
transform: scale(1.08);
box-shadow: 0 6px 18px rgba(0, 204, 255, 0.6);
background: linear-gradient(135deg, #00ccff, #00ff99);
}
@media (max-width: 600px) {
h2 {
font-size: 1.5rem;
}
#box {
width: 150px;
height: 150px;
}
}
</style>
</head>
<body>
<!-- ✅ Grid -->
<div class="grid"></div>
<h2>🎯 CSS Resizer Playground</h2>
<div id="box"></div>
<div id="dimensions">Width: 200px | Height: 200px</div>
<div class="controls">
<label for="unit">Unit:</label>
<select id="unit">
<option value="px">px</option>
<option value="%">%</option>
<option value="em">em</option>
<option value="rem">rem</option>
</select>
<label for="minWidth">Min Width:</label>
<input type="range" id="minWidth" min="20" max="500" value="20">
<label for="maxWidth">Max Width:</label>
<input type="range" id="maxWidth" min="200" max="1000" value="1000">
<button onclick="exportCode()">📤 Export Code</button>
</div>
<div id="exportedCode" hidden></div>
<!-- ⭐ About Section -->
<section class="about">
<h2>👨💻 About the Developer</h2>
<p>
Hi, I’m <strong>Mohammed Owais</strong>, a BCA student passionate about
<em>web development, problem solving, and cybersecurity</em>.
This project <strong>BoxCraft</strong> was built to help beginners
understand CSS sizing and the box model visually.
</p>
<a href="https://github.com/MRSE435" target="_blank" class="btn">
🔗 Visit My GitHub
</a>
</section>
<script>
const box = document.getElementById('box');
const dim = document.getElementById('dimensions');
const unitSelector = document.getElementById('unit');
const minW = document.getElementById('minWidth');
const maxW = document.getElementById('maxWidth');
const exportDiv = document.getElementById('exportedCode');
let unit = 'px';
function updateSize() {
let width = box.offsetWidth;
let height = box.offsetHeight;
if (unit === '%') {
width = ((box.offsetWidth / box.parentElement.offsetWidth) * 100).toFixed(1);
height = ((box.offsetHeight / box.parentElement.offsetHeight) * 100).toFixed(1);
} else if (unit === 'em' || unit === 'rem') {
width = (box.offsetWidth / 16).toFixed(2);
height = (box.offsetHeight / 16).toFixed(2);
}
dim.textContent = `Width: ${width}${unit} | Height: ${height}${unit}`;
}
unitSelector.addEventListener('change', () => {
unit = unitSelector.value;
updateSize();
});
minW.addEventListener('input', () => {
box.style.minWidth = `${minW.value}px`;
});
maxW.addEventListener('input', () => {
box.style.maxWidth = `${maxW.value}px`;
});
function exportCode() {
const width = box.offsetWidth;
const height = box.offsetHeight;
const code = `
<!-- HTML -->
<div class="box"></div>
<!-- CSS -->
<style>
.box {
width: ${width}${unit};
height: ${height}${unit};
border: 2px dashed #00ff99;
background-color: #111;
resize: both;
overflow: auto;
}
</style>`;
exportDiv.hidden = false;
exportDiv.textContent = code.trim();
}
const observer = new ResizeObserver(updateSize);
observer.observe(box);
</script>
</body>
</html>