Oto zaawansowana 3D galeria zdjęć z wykorzystaniem CSS 3D transformacji , animacji i darmowych zdjęć z Unsplash . Strona umożliwia rotację galeryjnego "kostki" (3D cube), gdzie każda ściana zawiera obrazek z bazy Unsplash. Wersja zawiera animacje, interaktywność oraz responsywność .
✅ Wymagania
HTML + CSS (bez JavaScriptu) – prosty kod, który działa w większości przeglądarek.
Darmowe zdjęcia z Unsplash (losowe, z kategorii np. "nature", "technology").
3D efekt za pomocą transform-style: preserve-3d.
📄 Kod HTML + CSS
html Copy code
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>3D Galeria Zdjęć</title>
<style>
body {
margin: 0;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: #111;
color: #fff;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.gallery-container {
perspective: 1000px;
width: 300px;
height: 300px;
margin: 20px auto;
}
.cube {
width: 100%;
height: 100%;
position: relative;
transform-style: preserve-3d;
animation: rotate 10s infinite linear;
}
.cube:hover {
animation-play-state: paused;
}
.face {
position: absolute;
width: 100%;
height: 100%;
background-size: cover;
background-position: center;
border-radius: 10px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
transition: transform 0.5s ease-in-out;
}
.face:nth-child(1) { transform: rotateY(0deg) translateZ(150px); }
.face:nth-child(2) { transform: rotateY(90deg) translateZ(150px); }
.face:nth-child(3) { transform: rotateY(180deg) translateZ(150px); }
.face:nth-child(4) { transform: rotateY(-90deg) translateZ(150px); }
.face:nth-child(5) { transform: rotateX(90deg) translateZ(150px); }
.face:nth-child(6) { transform: rotateX(-90deg) translateZ(150px); }
@keyframes rotate {
from { transform: rotateY(0deg); }
to { transform: rotateY(360deg); }
}
/* Responsywność */
@media (max-width: 600px) {
.gallery-container {
width: 250px;
height: 250px;
}
}
</style>
</head>
<body>
<div class="gallery-container">
<div class="cube">
<div class="face" style="background-image: url('https://source.unsplash.com/400x300/?nature');"></div>
<div class="face" style="background-image: url('https://source.unsplash.com/400x300/?technology');"></div>
<div class="face" style="background-image: url('https://source.unsplash.com/400x300/?city');"></div>
<div class="face" style="background-image: url('https://source.unsplash.com/400x300/?people');"></div>
<div class="face" style="background-image: url('https://source.unsplash.com/400x300/?food');"></div>
<div class="face" style="background-image: url('https://source.unsplash.com/400x300/?travel');"></div>
</div>
</div>
</body>
</html>
🎨 Funkcjonalności
3D kostka (cube) z 6 ścianami.
Animacja rotacji (360°) za pomocą @keyframes.
Zdjęcia z Unsplash – losowe obrazki z różnych kategorii (np. nature, technology, city).
Interaktywność : Kliknięcie na kostkę zatrzymuje animację.
Responsywność : Działa na urządzeniach mobilnych.
🌐 Przykładowe kategorie zdjęć
Możesz zmieniać kategorie w URLach:
nature – krajobrazy
technology – tech
city – miasta
people – ludzie
food – jedzenie
travel – podróże
💡 Dodatkowe ulepszenia
Jeśli chcesz dodać więcej interaktywności:
Przyciski do ręcznego rotowania (z JavaScriptem).
Efekt „3D flip” przy kliknięciu.
Dodanie tekstów na każdej ścianie .
📦 Jak używać?
Skopiuj kod do pliku .html.
Otwórz w przeglądarce.
Zobacz, jak kostka się obraca.
Dostosuj kategorie zdjęć i kolorystykę.
Chcesz, żebym dodał interaktywne przyciski do rotacji lub efekty 3D flip ? Chętnie pomogę! 😊