-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathscreen-resolution-tester.html
More file actions
297 lines (284 loc) · 9.37 KB
/
Copy pathscreen-resolution-tester.html
File metadata and controls
297 lines (284 loc) · 9.37 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
287
288
289
290
291
292
293
294
295
296
297
<!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="Test your website at different screen resolutions." />
<title>Screen Resolution Tester — One File Tools</title>
<style>
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
:root {
--bg: #fafafa;
--surface: #f1f5f9;
--text: #1a1a1a;
--muted: #64748b;
--border: #e2e8f0;
--accent: #2563eb;
--radius: 8px;
}
@media (prefers-color-scheme: dark) {
:root {
--bg: #0a0a0a;
--surface: #1a1a1a;
--text: #e5e5e5;
--muted: #94a3b8;
--border: #334155;
--accent: #3b82f6;
}
}
body {
font-family: system-ui, sans-serif;
line-height: 1.6;
background: var(--bg);
color: var(--text);
min-height: 100vh;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 2rem;
}
header {
text-align: center;
margin-bottom: 2rem;
}
header h1 {
font-size: 2rem;
margin-bottom: 0.5rem;
}
header p {
color: var(--muted);
}
.card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 1.5rem;
margin-bottom: 1.5rem;
overflow: hidden;
}
.card-header {
font-weight: 600;
margin-bottom: 1rem;
color: var(--text);
}
.current-info {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
gap: 1rem;
text-align: center;
margin-bottom: 1.5rem;
}
.info-item {
background: var(--bg);
padding: 1rem;
border-radius: var(--radius);
overflow: hidden;
}
.info-value {
font-size: 1.5rem;
font-weight: 700;
color: var(--accent);
overflow-wrap: break-word;
}
.info-label {
font-size: 0.75rem;
color: var(--muted);
text-transform: uppercase;
}
.presets {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
margin-bottom: 1rem;
}
.preset {
padding: 0.5rem 1rem;
border: 1px solid var(--border);
border-radius: var(--radius);
background: var(--bg);
color: var(--text);
cursor: pointer;
font-size: 0.875rem;
}
.preset:hover {
border-color: var(--accent);
}
.preset.active {
background: var(--accent);
color: white;
border-color: var(--accent);
}
.viewport-wrap {
max-width: 100%;
max-height: 70vh;
overflow: auto;
border-radius: var(--radius);
background: var(--bg);
}
.viewport {
border: 2px solid var(--accent);
border-radius: var(--radius);
overflow: hidden;
position: relative;
transition: all 0.3s;
}
.viewport iframe {
width: 100%;
height: 500px;
border: none;
background: white;
display: block;
}
.viewport-bar {
position: sticky;
top: 0;
left: 0;
right: 0;
background: var(--accent);
color: white;
padding: 0.5rem;
font-size: 0.75rem;
text-align: center;
white-space: nowrap;
z-index: 1;
}
footer {
text-align: center;
padding: 2rem;
color: var(--muted);
font-size: 0.875rem;
}
footer a {
color: var(--accent);
text-decoration: none;
}
</style>
</head>
<body>
<div class="container">
<header>
<h1>📱 Screen Resolution Tester</h1>
<p>Test your website at different screen sizes</p>
</header>
<div class="card">
<div class="card-header">Your Current Screen</div>
<div class="current-info">
<div class="info-item">
<div class="info-value" id="screenWidth">-</div>
<div class="info-label">Screen Width</div>
</div>
<div class="info-item">
<div class="info-value" id="screenHeight">-</div>
<div class="info-label">Screen Height</div>
</div>
<div class="info-item">
<div class="info-value" id="windowWidth">-</div>
<div class="info-label">Window Width</div>
</div>
<div class="info-item">
<div class="info-value" id="windowHeight">-</div>
<div class="info-label">Window Height</div>
</div>
<div class="info-item">
<div class="info-value" id="devicePixelRatio">-</div>
<div class="info-label">Pixel Ratio</div>
</div>
</div>
</div>
<div class="card">
<div class="card-header">Quick Presets</div>
<div class="presets">
<button class="preset" data-w="375" data-h="667">iPhone SE</button>
<button class="preset" data-w="390" data-h="844">iPhone 12</button>
<button class="preset" data-w="414" data-h="896">iPhone 11</button>
<button class="preset" data-w="768" data-h="1024">iPad</button>
<button class="preset" data-w="1024" data-h="768">iPad Landscape</button>
<button class="preset" data-w="1280" data-h="720">HD</button>
<button class="preset" data-w="1366" data-h="768">Laptop</button>
<button class="preset" data-w="1920" data-h="1080">Full HD</button>
<button class="preset" data-w="2560" data-h="1440">2K</button>
<button class="preset" data-w="3840" data-h="2160">4K</button>
</div>
<div style="display: flex; gap: 1rem; margin-bottom: 1rem">
<div style="flex: 1">
<label style="font-size: 0.75rem; color: var(--muted)">Width</label>
<input type="number" id="customWidth" value="1280" style="width: 100%; padding: 0.5rem; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--text)" />
</div>
<div style="flex: 1">
<label style="font-size: 0.75rem; color: var(--muted)">Height</label>
<input type="number" id="customHeight" value="720" style="width: 100%; padding: 0.5rem; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--text)" />
</div>
<button id="applyBtn" style="align-self: flex-end; padding: 0.5rem 1rem; background: var(--accent); color: white; border: none; border-radius: 4px; cursor: pointer">Apply</button>
</div>
<div class="viewport-wrap">
<div class="viewport" id="viewport">
<div class="viewport-bar" id="viewportBar">1280 x 720</div>
<iframe id="iframe" src="about:blank"></iframe>
</div>
</div>
</div>
</div>
<footer>
<p>Part of <a href="https://github.com/praveenscience/One-File-Tools">One File Tools</a></p>
</footer>
<script>
var screenWidth = document.getElementById("screenWidth");
var screenHeight = document.getElementById("screenHeight");
var windowWidth = document.getElementById("windowWidth");
var windowHeight = document.getElementById("windowHeight");
var devicePixelRatio = document.getElementById("devicePixelRatio");
var viewport = document.getElementById("viewport");
var viewportBar = document.getElementById("viewportBar");
var iframe = document.getElementById("iframe");
var customWidth = document.getElementById("customWidth");
var customHeight = document.getElementById("customHeight");
var applyBtn = document.getElementById("applyBtn");
var lastUrl = "https://example.com";
function updateInfo() {
screenWidth.textContent = screen.width;
screenHeight.textContent = screen.height;
windowWidth.textContent = window.innerWidth;
windowHeight.textContent = window.innerHeight;
devicePixelRatio.textContent = window.devicePixelRatio;
}
function setViewport(w, h) {
viewport.style.width = w + "px";
viewport.style.height = h + 30 + "px";
iframe.style.height = h + "px";
viewportBar.textContent = w + " x " + h;
customWidth.value = w;
customHeight.value = h;
document.querySelectorAll(".preset").forEach(function (btn) {
btn.classList.toggle("active", parseInt(btn.dataset.w) === w && parseInt(btn.dataset.h) === h);
});
}
function promptUrl() {
var url = prompt("Enter URL to test:", lastUrl);
if (url) {
if (!url.match(/^https?:\/\//)) url = "https://" + url;
lastUrl = url;
iframe.src = url;
}
}
document.querySelectorAll(".preset").forEach(function (btn) {
btn.onclick = function () {
setViewport(parseInt(btn.dataset.w), parseInt(btn.dataset.h));
};
});
applyBtn.onclick = function () {
setViewport(parseInt(customWidth.value), parseInt(customHeight.value));
};
viewport.onclick = promptUrl;
window.addEventListener("resize", updateInfo);
updateInfo();
setViewport(1280, 720);
</script>
</body>
</html>