-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathlist to grid.html
More file actions
52 lines (48 loc) · 1.15 KB
/
list to grid.html
File metadata and controls
52 lines (48 loc) · 1.15 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
<html>
<style>
/* Default Grid View */
.grid-view .item {
display: inline-block;
width: 200px;
height: 200px;
margin: 10px;
background-color: #f3f3f3;
text-align: center;
vertical-align: middle;
}
/* List View */
.list-view .item {
display: block;
width: 100%;
height: auto;
margin: 5px 0;
background-color: #e3e3e3;
padding: 10px;
text-align: left;
}
</style>
<body>
<div class="view-toggle">
<button onclick="toggleView('grid')">Grid View</button>
<button onclick="toggleView('list')">List View</button>
</div>
<div id="container" class="grid-view">
<div class="item">Item 1</div>
<div class="item">Item 2</div>
<div class="item">Item 3</div>
<!-- Add more items as needed -->
</div>
<script type="text/javascript">
function toggleView(view) {
const container = document.getElementById('container');
if (view === 'grid') {
container.classList.add('grid-view');
container.classList.remove('list-view');
} else if (view === 'list') {
container.classList.add('list-view');
container.classList.remove('grid-view');
}
}
</script>
</body>
</html>