Swordartoffline's picture
Add 3 files
658b1b9 verified
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Right-to-Left Image Carousel</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
.carousel-container {
width: 100%;
overflow: hidden;
position: relative;
}
.carousel-track {
display: flex;
transition: transform 0.5s ease-in-out;
}
.carousel-slide {
min-width: 100%;
box-sizing: border-box;
}
.carousel-slide img {
width: 100%;
height: auto;
object-fit: cover;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.carousel-nav {
position: absolute;
bottom: 20px;
left: 20px;
z-index: 10;
}
.carousel-btn {
background-color: rgba(255, 255, 255, 0.7);
color: #333;
border: none;
padding: 8px 16px;
border-radius: 20px;
cursor: pointer;
font-weight: bold;
transition: all 0.3s ease;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.carousel-btn:hover {
background-color: rgba(255, 255, 255, 0.9);
transform: translateY(-2px);
}
.carousel-btn:active {
transform: translateY(0);
}
.slide-indicators {
display: flex;
justify-content: center;
margin-top: 15px;
}
.indicator {
width: 10px;
height: 10px;
border-radius: 50%;
background-color: #ccc;
margin: 0 5px;
cursor: pointer;
transition: background-color 0.3s ease;
}
.indicator.active {
background-color: #555;
}
</style>
</head>
<body class="bg-gray-100 min-h-screen flex flex-col items-center justify-center p-4">
<div class="max-w-4xl w-full bg-white rounded-xl shadow-lg overflow-hidden p-6">
<h1 class="text-3xl font-bold text-center text-gray-800 mb-8">Nature Gallery</h1>
<div class="carousel-container relative">
<div class="carousel-track" id="carouselTrack">
<div class="carousel-slide">
<img src="https://source.unsplash.com/random/800x500/?mountain" alt="Mountain landscape">
<div class="absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-4">
<h3 class="text-white text-xl font-semibold">Mountain Majesty</h3>
<p class="text-white/80">The breathtaking views of alpine peaks</p>
</div>
</div>
<div class="carousel-slide">
<img src="https://source.unsplash.com/random/800x500/?forest" alt="Forest landscape">
<div class="absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-4">
<h3 class="text-white text-xl font-semibold">Enchanted Forest</h3>
<p class="text-white/80">The mysterious beauty of ancient woods</p>
</div>
</div>
<div class="carousel-slide">
<img src="https://source.unsplash.com/random/800x500/?ocean" alt="Ocean landscape">
<div class="absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-4">
<h3 class="text-white text-xl font-semibold">Ocean Waves</h3>
<p class="text-white/80">The endless dance of sea and shore</p>
</div>
</div>
<div class="carousel-slide">
<img src="https://source.unsplash.com/random/800x500/?desert" alt="Desert landscape">
<div class="absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-4">
<h3 class="text-white text-xl font-semibold">Desert Sands</h3>
<p class="text-white/80">The golden expanse of shifting dunes</p>
</div>
</div>
<div class="carousel-slide">
<img src="https://source.unsplash.com/random/800x500/?waterfall" alt="Waterfall landscape">
<div class="absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-4">
<h3 class="text-white text-xl font-semibold">Cascading Waters</h3>
<p class="text-white/80">The powerful flow of nature's force</p>
</div>
</div>
</div>
<div class="carousel-nav">
<button class="carousel-btn" id="nextBtn">Next →</button>
</div>
</div>
<div class="slide-indicators mt-4" id="indicators">
<!-- Indicators will be added by JavaScript -->
</div>
<div class="mt-8 text-center text-gray-600">
<p>Click the "Next" button to see more beautiful nature scenes</p>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const track = document.getElementById('carouselTrack');
const nextBtn = document.getElementById('nextBtn');
const indicatorsContainer = document.getElementById('indicators');
const slides = document.querySelectorAll('.carousel-slide');
let currentIndex = 0;
// Create indicators
slides.forEach((_, index) => {
const indicator = document.createElement('div');
indicator.classList.add('indicator');
if (index === 0) indicator.classList.add('active');
indicator.addEventListener('click', () => {
goToSlide(index);
});
indicatorsContainer.appendChild(indicator);
});
const indicators = document.querySelectorAll('.indicator');
function updateCarousel() {
track.style.transform = `translateX(-${currentIndex * 100}%)`;
// Update indicators
indicators.forEach((indicator, index) => {
if (index === currentIndex) {
indicator.classList.add('active');
} else {
indicator.classList.remove('active');
}
});
}
function goToSlide(index) {
currentIndex = index;
updateCarousel();
}
function nextSlide() {
currentIndex = (currentIndex + 1) % slides.length;
updateCarousel();
}
nextBtn.addEventListener('click', nextSlide);
// Auto-advance every 5 seconds (optional)
let autoSlide = setInterval(nextSlide, 5000);
// Pause auto-slide on hover
track.parentElement.addEventListener('mouseenter', () => {
clearInterval(autoSlide);
});
track.parentElement.addEventListener('mouseleave', () => {
autoSlide = setInterval(nextSlide, 5000);
});
// Touch support for mobile devices
let touchStartX = 0;
let touchEndX = 0;
track.addEventListener('touchstart', (e) => {
touchStartX = e.changedTouches[0].screenX;
});
track.addEventListener('touchend', (e) => {
touchEndX = e.changedTouches[0].screenX;
handleSwipe();
});
function handleSwipe() {
if (touchEndX < touchStartX) {
// Swipe left - next slide
nextSlide();
}
}
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Swordartoffline/test-001a-deepsite-imagecarouselhtml" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>