Text label and gallery
March 31, 2025 ยท AI Conversations
text label may be many more
For example:
– In a **WordPress** environment (e.g., Elementor, Gutenberg, ACF)?
– In a **Vue** or **React** component?
– In plain **HTML/CSS/JS**?
– Or somewhere else like **Laravel Blade**, **WooCommerce**, etc.?
In the meantime, here's a **generic HTML example** that shows a **text label** followed by a **multiple image gallery**:
“`html
My Gallery Label: Many more descriptions can go here if needed
1. A **text label** (which can be long).
2. A **multiple image gallery**.
3. Images can be added dynamically through JavaScript.
—
### โ HTML + JavaScript Gallery with Label
“`html
Image Gallery
.gallery-container {
max-width: 800px;
margin: 20px auto;
font-family: sans-serif;
}
.gallery-label {
font-size: 1.5rem;
margin-bottom: 10px;
}
.image-gallery
– Adds a **text label** (which can be long/multiple lines).
– Displays a **multiple image gallery**.
– Uses **JavaScript** to add images dynamically.
—
### โ Full HTML + JavaScript Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Image Gallery</title>
<style>
.gallery-container {
max-width: 800px;
margin: 20px auto;
font-family: Arial, sans-serif;
}
.gallery-label {
font-size: 20px;
font-weight: bold;
margin-bottom: 10px;
color: #333;
}
.image-gallery {
display: flex;
flex-wrap: wrap;
gap: 10px;
}
.image-gallery img {
width: 150px;
height: 100px;
object-fit: cover;
border: 2px solid #ccc;
border-radius: 8px;
}
</style>
</head>
<body>
<div class="gallery-container">
<div id="label" class="gallery-label"></div>
<div id="gallery" class="image-gallery"></div>
</div>
<script>
// Set a long label
const labelText = "Welcome to the image gallery. This gallery contains many beautiful images. Enjoy viewing!";
document.getElementById("label").textContent = labelText;
// Array of image URLs
const imageUrls = [
'https://via.placeholder.com/300x200?text=Image+1',
'https://via.placeholder.com/300x200?text=Image+2',
'https://via.placeholder.com/300x200?text=Image+3',
'https://via.placeholder.com/300x200?text=Image+4',
'https://via.placeholder.com/300x200?text=Image+5'
];
// Add images to gallery
const gallery = document.getElementById("gallery");
imageUrls.forEach(url => {
const img = document.createElement("img");
img.src = url;
gallery.appendChild(img);
});
</script>
</body>
</html>
—
Let me know if you want to:
– Load images from a local folder or API,
– Add click events,
– Or make it editable/uploadable by the user.
– There's a **label**.
– You can click an **"Add More Images"** button.
– Clicking the button dynamically adds more images to the gallery.
—
### โ HTML + JavaScript with "Add More" Button
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Dynamic Image Gallery</title>
<style>
.gallery-container {
max-width: 800px;
margin: 20px auto;
font-family: Arial, sans-serif;
}
.gallery-label {
font-size: 20px;
font-weight: bold;
margin-bottom: 10px;
}
.image-gallery {
display: flex;
flex-wrap: wrap;
gap: 10px;
margin-bottom: 20px;
}
.image-gallery img {
width: 150px;
height: 100px;
object-fit: cover;
border: 2px solid #ccc;
border-radius: 8px;
}
button {
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
}
</style>
</head>
<body>
<div class="gallery-container">
<div id="label" class="gallery-label">
This is a dynamic image gallery. Click the button below to add more images.
</div>
<div id="gallery" class="image-gallery"></div>
<button onclick="addMoreImages()">Add More Images</button>
</div>
<script>
let imageCounter = 1;
function addMoreImages() {
const gallery = document.getElementById("gallery");
// Add 3 new images on each click
for (let i = 0; i < 3; i++) {
const img = document.createElement("img");
img.src = `https://via.placeholder.com/300x200?text=Image+${imageCounter++}`;
gallery.appendChild(img);
}
}
// Optional: Add initial images
addMoreImages();
</script>
</body>
</html>
—
Let me know if you want users to **upload their own images** or select from local files instead!