forked from you-dont-need/You-Dont-Need-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCSS-grid layout generator.html
More file actions
95 lines (84 loc) · 2.52 KB
/
Copy pathCSS-grid layout generator.html
File metadata and controls
95 lines (84 loc) · 2.52 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS Grid Layout Generator</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
background-color: #f0f0f0;
}
h1 {
margin-bottom: 20px;
}
.controls {
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 20px;
}
.controls label {
margin: 5px 0;
}
.grid-container {
display: grid;
width: 80%;
max-width: 600px;
height: 400px;
background-color: #ffffff;
border: 1px solid #ddd;
}
.grid-item {
background-color: #4CAF50;
border: 1px solid #333;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 18px;
}
/* Grid configuration based on CSS variables */
.grid-container {
grid-template-rows: repeat(var(--rows, 2), 1fr);
grid-template-columns: repeat(var(--columns, 2), 1fr);
gap: var(--gap, 10px);
}
/* Slider styling */
input[type="range"] {
width: 200px;
margin: 5px 0;
}
</style>
</head>
<body>
<h1>CSS Grid Layout Generator</h1>
<div class="controls">
<label>
Rows:
<input type="range" min="1" max="6" value="2" oninput="document.documentElement.style.setProperty('--rows', this.value)">
</label>
<label>
Columns:
<input type="range" min="1" max="6" value="2" oninput="document.documentElement.style.setProperty('--columns', this.value)">
</label>
<label>
Gap (px):
<input type="range" min="0" max="50" value="10" oninput="document.documentElement.style.setProperty('--gap', this.value + 'px')">
</label>
</div>
<div class="grid-container">
<div class="grid-item">1</div>
<div class="grid-item">2</div>
<div class="grid-item">3</div>
<div class="grid-item">4</div>
<div class="grid-item">5</div>
<div class="grid-item">6</div>
</div>
</body>
</html>