Sure! Below are the full codes for each file needed to create your interactive slideshow website. You can copy and paste these into Visual Studio Code. Make sure all files are in the same folder. Once done, you can run the website by right-clicking on index.html and selecting "Open with Live Server".
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Interactive Slideshow</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="slideshow-container">
<button class="nav-button prev" onclick="prevSlide()">❮</button>
<div class="slideshow">
<!-- Slides will be dynamically added here -->
</div>
<button class="nav-button next" onclick="nextSlide()">❯</button>
</div>
<div class="controls">
<button class="upload-btn" onclick="uploadImages()">Upload Pictures</button>
<input type="file" id="imageUpload" accept="image/*" multiple style="display: none;">
</div>
<div class="slide-info">
<div class="rating">
<span class="star" data-value="5">★</span>
<span class="star" data-value="4">★</span>
<span class="star" data-value="3">★</span>
<span class="star" data-value="2">★</span>
<span class="star" data-value="1">★</span>
</div>
<textarea id="review" placeholder="Write your review here"></textarea>
</div>
<script src="script.js"></script>
</body>
</html>
styles.css
/* General Styles */
body {
background-color: black;
color: white;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin: 0;
overflow-x: hidden;
}
h1 {
text-align: center;
margin-top: 30px;
}
.slideshow-container {
position: relative;
width: 80%;
max-width: 1000px;
height: 500px;
margin: 50px auto 0;
overflow: hidden;
perspective: 1000px;
}
.slideshow {
position: relative;
width: 100%;
height: 100%;
}
.slide {
position: absolute;
top: 0;
left: 50%;
width: 60%;
height: 100%;
opacity: 0;
transform-origin: center center;
transition: all 0.5s ease;
transform-style: preserve-3d;
backface-visibility: hidden;
}
.slide img {
width: 100%;
height: 100%;
object-fit: cover;
border-radius: 10px;
}
.slide.active {
opacity: 1;
transform: translateX(-50%) scale(1) translateZ(0px);
z-index: 2;
}
.slide.left {
opacity: 0.5;
transform: translateX(-150%) scale(0.8) translateZ(-200px) rotateY(45deg);
z-index: 1;
}
.slide.right {
opacity: 0.5;
transform: translateX(50%) scale(0.8) translateZ(-200px) rotateY(-45deg);
z-index: 1;
}
.nav-button {
cursor: pointer;
position: absolute;
top: 50%;
width: 60px;
height: 60px;
margin-top: -30px;
color: white;
font-size: 40px;
background-color: rgba(255, 255, 255, 0.1);
border: none;
outline: none;
border-radius: 50%;
text-align: center;
line-height: 60px;
transition: background-color 0.3s;
}
.nav-button:hover {
background-color: rgba(255, 255, 255, 0.3);
}
.prev {
left: 20px;
}
.next {
right: 20px;
}
.controls {
text-align: center;
margin: 20px 0;
}
.upload-btn {
padding: 10px 20px;
font-size: 16px;
background-color: #1c1c1c;
color: white;
border: 1px solid #555;
border-radius: 5px;
cursor: pointer;
}
.upload-btn:hover {
background-color: #333;
}
.slide-info {
text-align: center;
max-width: 800px;
margin: 30px auto;
}
.rating {
direction: rtl;
unicode-bidi: bidi-override;
font-size: 3em;
display: inline-block;
}
.rating .star {
display: inline-block;
color: grey;
cursor: pointer;
transition: color 0.2s;
}
.rating .star:hover,
.rating .star:hover ~ .star,
.rating .star.selected,
.rating .star.selected ~ .star {
color: gold;
}
#review {
width: 80%;
max-width: 600px;
height: 150px;
margin-top: 20px;
background-color: #222;
color: white;
border: 1px solid #555;
border-radius: 5px;
font-size: 1em;
padding: 10px;
}
#review::placeholder {
color: #999;
}
script.js
let slideIndex = 0;
let slides = [];
let ratings = {};
let reviews = {};
const slideshow = document.querySelector('.slideshow');
const ratingStars = document.querySelectorAll('.rating .star');
const reviewTextarea = document.getElementById('review');
function showSlide(index) {
if (slides.length === 0) return;
slideIndex = (index + slides.length) % slides.length;
slides.forEach((slide, i) => {
slide.classList.remove('active', 'left', 'right');
slide.style.opacity = '0';
slide.style.transform = 'translateX(-50%) scale(0.5) translateZ(-500px)';
if (i === slideIndex) {
slide.classList.add('active');
} else if (i === (slideIndex - 1 + slides.length) % slides.length) {
slide.classList.add('left');
} else if (i === (slideIndex + 1) % slides.length) {
slide.classList.add('right');
}
});
updateRating();
updateReview();
}
function nextSlide() {
showSlide(slideIndex + 1);
}
function prevSlide() {
showSlide(slideIndex - 1);
}
function uploadImages() {
document.getElementById('imageUpload').click();
}
document.getElementById('imageUpload').addEventListener('change', handleFiles);
function handleFiles() {
const files = this.files;
for (let i = 0; i < files.length; i++) {
const file = files[i];
const img = document.createElement('img');
img.src = URL.createObjectURL(file);
img.onload = function() {
URL.revokeObjectURL(this.src);
}
const slide = document.createElement('div');
slide.className = 'slide';
slide.appendChild(img);
slideshow.appendChild(slide);
slides.push(slide);
}
showSlide(slideIndex);
}
ratingStars.forEach(star => {
star.addEventListener('click', function() {
const value = this.getAttribute('data-value');
ratings[getCurrentImageSrc()] = value;
updateRating();
saveData();
});
});
function updateRating() {
const currentRating = ratings[getCurrentImageSrc()] || 0;
ratingStars.forEach(star => {
if (parseInt(star.getAttribute('data-value')) <= currentRating) {
star.classList.add('selected');
} else {
star.classList.remove('selected');
}
});
}
reviewTextarea.addEventListener('input', function() {
reviews[getCurrentImageSrc()] = this.value;
saveData();
});
function updateReview() {
reviewTextarea.value = reviews[getCurrentImageSrc()] || '';
}
function getCurrentImageSrc() {
const img = slides[slideIndex].querySelector('img');
return img ? img.src : '';
}
function saveData() {
localStorage.setItem('ratings', JSON.stringify(ratings));
localStorage.setItem('reviews', JSON.stringify(reviews));
}
function loadData() {
const storedRatings = localStorage.getItem('ratings');
const storedReviews = localStorage.getItem('reviews');
if (storedRatings) {
ratings = JSON.parse(storedRatings);
}
if (storedReviews) {
reviews = JSON.parse(storedReviews);
}
}
window.onload = function() {
loadData();
};
Instructions:
-
Create the Files:
- Open Visual Studio Code.
- Create a new folder for your project.
- Inside the folder, create three new files:
index.html
styles.css
script.js
-
Copy and Paste the Code:
- Copy the code provided for each file and paste it into the corresponding file in Visual Studio Code.
-
Run the Live Server:
- Install the Live Server extension in Visual Studio Code if you haven't already.
- Right-click on
index.html and select "Open with Live Server".
- Your website should now open in your default browser.
-
Using the Website:
-
Data Persistence:
- The ratings and reviews are saved using the browser's Local Storage.
- This means your data will be preserved between sessions on the same browser.
Features Implemented:
- Black Background: The website has a black background for a sleek look.
- Image Upload: You can upload images directly from your computer to the slideshow.
- Interactive Slideshow:
- Images are displayed in a carousel format.
- Adjacent images are slightly visible on the sides, creating a 3D effect.
- Centralized Content: All elements are centered and neatly organized.
- Interactive 5-Star Rating System:
- Clickable stars beneath each image.
- Ratings are saved individually for each image.
- Review Section:
- A larger text area to write reviews.
- Reviews are saved individually for each image.
- Modern and Futuristic Design:
- Minimalistic style with smooth transitions.
- Hover effects on buttons and stars.
- Responsive Design: The layout adjusts based on the screen size.
Notes:
Feel free to customize the styles in styles.css to further enhance the futuristic look or adjust any settings to better suit your preferences. Enjoy your new interactive slideshow website!