Spaces:
Running
Running
Update index.html
Browse files- index.html +212 -8
index.html
CHANGED
|
@@ -1,18 +1,222 @@
|
|
| 1 |
-
|
| 2 |
<!DOCTYPE html>
|
| 3 |
<html lang="en">
|
| 4 |
<head>
|
| 5 |
<meta charset="UTF-8">
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 7 |
<title>Image Gallery</title>
|
| 8 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
</head>
|
| 10 |
<body>
|
| 11 |
-
<div class="
|
| 12 |
-
<
|
| 13 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
</div>
|
| 15 |
-
<div class="
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
</body>
|
| 18 |
-
</html>
|
|
|
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>Image Gallery</title>
|
| 7 |
+
<style>
|
| 8 |
+
* {
|
| 9 |
+
margin: 0;
|
| 10 |
+
padding: 0;
|
| 11 |
+
box-sizing: border-box;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
body {
|
| 15 |
+
font-family: Arial, sans-serif;
|
| 16 |
+
padding: 20px;
|
| 17 |
+
background: #f0f0f0;
|
| 18 |
+
min-height: 100vh;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
.container {
|
| 22 |
+
max-width: 1200px;
|
| 23 |
+
margin: 0 auto;
|
| 24 |
+
padding: 20px;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
h1 {
|
| 28 |
+
font-size: 2rem;
|
| 29 |
+
color: #262626;
|
| 30 |
+
margin-bottom: 1.5rem;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
.upload-zone {
|
| 34 |
+
border: 2px dashed #ccc;
|
| 35 |
+
padding: 40px;
|
| 36 |
+
text-align: center;
|
| 37 |
+
margin-bottom: 20px;
|
| 38 |
+
cursor: pointer;
|
| 39 |
+
background: white;
|
| 40 |
+
transition: border-color 0.3s;
|
| 41 |
+
border-radius: 8px;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
.upload-zone:hover {
|
| 45 |
+
border-color: #405DE6;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
.upload-zone.dragging {
|
| 49 |
+
border-color: #405DE6;
|
| 50 |
+
background: #f0f7ff;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
.upload-icon {
|
| 54 |
+
width: 48px;
|
| 55 |
+
height: 48px;
|
| 56 |
+
margin-bottom: 1rem;
|
| 57 |
+
color: #405DE6;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
.upload-text {
|
| 61 |
+
font-size: 1.125rem;
|
| 62 |
+
font-weight: 600;
|
| 63 |
+
margin-bottom: 0.5rem;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
.upload-subtext {
|
| 67 |
+
font-size: 0.875rem;
|
| 68 |
+
color: #666;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
.gallery {
|
| 72 |
+
display: grid;
|
| 73 |
+
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
|
| 74 |
+
gap: 20px;
|
| 75 |
+
padding: 20px 0;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
.image-card {
|
| 79 |
+
position: relative;
|
| 80 |
+
background: white;
|
| 81 |
+
border-radius: 8px;
|
| 82 |
+
overflow: hidden;
|
| 83 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
.image-card img {
|
| 87 |
+
width: 100%;
|
| 88 |
+
height: 200px;
|
| 89 |
+
object-fit: cover;
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
.delete-btn {
|
| 93 |
+
position: absolute;
|
| 94 |
+
top: 10px;
|
| 95 |
+
right: 10px;
|
| 96 |
+
background: rgba(255,255,255,0.9);
|
| 97 |
+
border: none;
|
| 98 |
+
border-radius: 50%;
|
| 99 |
+
width: 30px;
|
| 100 |
+
height: 30px;
|
| 101 |
+
cursor: pointer;
|
| 102 |
+
display: flex;
|
| 103 |
+
align-items: center;
|
| 104 |
+
justify-content: center;
|
| 105 |
+
font-size: 18px;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
.delete-btn:hover {
|
| 109 |
+
background: rgba(255,0,0,0.9);
|
| 110 |
+
color: white;
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
.toast {
|
| 114 |
+
position: fixed;
|
| 115 |
+
bottom: 20px;
|
| 116 |
+
right: 20px;
|
| 117 |
+
background: #333;
|
| 118 |
+
color: white;
|
| 119 |
+
padding: 12px 24px;
|
| 120 |
+
border-radius: 4px;
|
| 121 |
+
display: none;
|
| 122 |
+
animation: slideIn 0.3s ease-out;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
@keyframes slideIn {
|
| 126 |
+
from { transform: translateY(100%); opacity: 0; }
|
| 127 |
+
to { transform: translateY(0); opacity: 1; }
|
| 128 |
+
}
|
| 129 |
+
</style>
|
| 130 |
</head>
|
| 131 |
<body>
|
| 132 |
+
<div class="container">
|
| 133 |
+
<h1>Image Gallery</h1>
|
| 134 |
+
<div class="upload-zone" id="uploadZone">
|
| 135 |
+
<svg class="upload-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
| 136 |
+
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
|
| 137 |
+
<polyline points="17 8 12 3 7 8"/>
|
| 138 |
+
<line x1="12" y1="3" x2="12" y2="15"/>
|
| 139 |
+
</svg>
|
| 140 |
+
<div class="upload-text">Click or drag and drop your images here</div>
|
| 141 |
+
<div class="upload-subtext">Supports: JPG, PNG, GIF</div>
|
| 142 |
+
<input type="file" id="fileInput" accept="image/*" multiple hidden>
|
| 143 |
+
</div>
|
| 144 |
+
<div class="gallery" id="gallery"></div>
|
| 145 |
</div>
|
| 146 |
+
<div class="toast" id="toast"></div>
|
| 147 |
+
|
| 148 |
+
<script>
|
| 149 |
+
const uploadZone = document.getElementById('uploadZone');
|
| 150 |
+
const fileInput = document.getElementById('fileInput');
|
| 151 |
+
const gallery = document.getElementById('gallery');
|
| 152 |
+
const toast = document.getElementById('toast');
|
| 153 |
+
|
| 154 |
+
let images = [];
|
| 155 |
+
|
| 156 |
+
function showToast(message, duration = 3000) {
|
| 157 |
+
toast.textContent = message;
|
| 158 |
+
toast.style.display = 'block';
|
| 159 |
+
setTimeout(() => {
|
| 160 |
+
toast.style.display = 'none';
|
| 161 |
+
}, duration);
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
uploadZone.addEventListener('click', () => fileInput.click());
|
| 165 |
+
|
| 166 |
+
uploadZone.addEventListener('dragover', (e) => {
|
| 167 |
+
e.preventDefault();
|
| 168 |
+
uploadZone.classList.add('dragging');
|
| 169 |
+
});
|
| 170 |
+
|
| 171 |
+
uploadZone.addEventListener('dragleave', () => {
|
| 172 |
+
uploadZone.classList.remove('dragging');
|
| 173 |
+
});
|
| 174 |
+
|
| 175 |
+
uploadZone.addEventListener('drop', (e) => {
|
| 176 |
+
e.preventDefault();
|
| 177 |
+
uploadZone.classList.remove('dragging');
|
| 178 |
+
handleFiles(e.dataTransfer.files);
|
| 179 |
+
});
|
| 180 |
+
|
| 181 |
+
fileInput.addEventListener('change', (e) => {
|
| 182 |
+
handleFiles(e.target.files);
|
| 183 |
+
fileInput.value = '';
|
| 184 |
+
});
|
| 185 |
+
|
| 186 |
+
function handleFiles(files) {
|
| 187 |
+
for (const file of files) {
|
| 188 |
+
if (file.type.startsWith('image/')) {
|
| 189 |
+
const reader = new FileReader();
|
| 190 |
+
reader.onload = (e) => {
|
| 191 |
+
const imageUrl = e.target.result;
|
| 192 |
+
addImage(imageUrl);
|
| 193 |
+
showToast('Image uploaded successfully');
|
| 194 |
+
};
|
| 195 |
+
reader.readAsDataURL(file);
|
| 196 |
+
}
|
| 197 |
+
}
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
function addImage(url) {
|
| 201 |
+
const id = Date.now();
|
| 202 |
+
images.push({ id, url });
|
| 203 |
+
renderGallery();
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
function deleteImage(id) {
|
| 207 |
+
images = images.filter(img => img.id !== id);
|
| 208 |
+
renderGallery();
|
| 209 |
+
showToast('Image deleted successfully');
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
function renderGallery() {
|
| 213 |
+
gallery.innerHTML = images.map(img => `
|
| 214 |
+
<div class="image-card">
|
| 215 |
+
<img src="${img.url}" alt="Gallery image">
|
| 216 |
+
<button class="delete-btn" onclick="deleteImage(${img.id})">×</button>
|
| 217 |
+
</div>
|
| 218 |
+
`).join('');
|
| 219 |
+
}
|
| 220 |
+
</script>
|
| 221 |
</body>
|
| 222 |
+
</html>
|