homepage images
parent
fd4a8164c4
commit
e2abab96ef
@ -0,0 +1,25 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Image Carousel</title>
|
||||
<link rel="stylesheet" href="css/styles.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="carousel">
|
||||
<div class="carousel-inner">
|
||||
<div class="carousel-item active">
|
||||
<img src="img/activty/greenScreen-4.png" alt="Image 1">
|
||||
</div>
|
||||
<div class="carousel-item">
|
||||
<img src="img/activty/20240730_153345.jpg" alt="Image 2">
|
||||
</div>
|
||||
<div class="carousel-item">
|
||||
<img src="img/activty/20240318_195731.jpg" alt="Image 3">
|
||||
</div>
|
||||
</div>
|
||||
<button class="carousel-control prev" onclick="prevSlide()">❮</button>
|
||||
<button class="carousel-control next" onclick="nextSlide()">❯</button>
|
||||
</div>
|
||||
|
||||
<script src="js/script.js"></script>
|
||||
</body>
|
@ -0,0 +1,58 @@
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
background-color: #f4f4f4;
|
||||
}
|
||||
|
||||
.carousel {
|
||||
position: relative;
|
||||
width: 150%;
|
||||
max-width: 1000px;
|
||||
overflow: hidden;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.carousel-inner {
|
||||
display: flex;
|
||||
transition: transform 2s ease-in-out;
|
||||
}
|
||||
|
||||
.carousel-item {
|
||||
min-width: 100%;
|
||||
transition: opacity 1.9s ease-in-out;
|
||||
}
|
||||
|
||||
.carousel-item img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain; /* Ensures the entire image fits within the carousel item */
|
||||
display: block;
|
||||
background-color: rgb(255, 255, 255); /* Optional: add a background color if there's empty space */
|
||||
}
|
||||
|
||||
|
||||
.carousel-control {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 10px;
|
||||
cursor: pointer;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.carousel-control.prev {
|
||||
left: 20px;
|
||||
}
|
||||
|
||||
.carousel-control.next {
|
||||
right: 20px;
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
let currentIndex = 0;
|
||||
|
||||
function showSlide(index) {
|
||||
const slides = document.querySelectorAll('.carousel-item');
|
||||
if (index >= slides.length) {
|
||||
currentIndex = 0;
|
||||
} else if (index < 0) {
|
||||
currentIndex = slides.length - 1;
|
||||
} else {
|
||||
currentIndex = index;
|
||||
}
|
||||
|
||||
const offset = -currentIndex * 100;
|
||||
document.querySelector('.carousel-inner').style.transform = `translateX(${offset}%)`;
|
||||
}
|
||||
|
||||
function nextSlide() {
|
||||
showSlide(currentIndex + 1);
|
||||
}
|
||||
|
||||
function prevSlide() {
|
||||
showSlide(currentIndex - 1);
|
||||
}
|
||||
|
||||
// Optional: Automatically move to the next slide every 3 seconds
|
||||
setInterval(nextSlide, 8000);
|
Loading…
Reference in New Issue