🖼️ Image Lightbox
Просмотр изображений в полноэкранном режиме
← Назад к Модальные окна
Simple Lightbox
HTML
<div class="lightbox-overlay">
<button class="lightbox-close">×</button>
<div class="lightbox-content">
<img src="https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=800" alt="Image">
</div>
</div>
CSS
.lightbox-overlay {
position: relative;
width: 100%;
min-height: 450px;
background: rgba(0, 0, 0, 0.9);
display: flex;
align-items: center;
justify-content: center;
padding: 2rem;
border-radius: 8px;
}
.lightbox-close {
position: absolute;
top: 1rem;
right: 1rem;
background: rgba(255, 255, 255, 0.2);
border: none;
color: white;
width: 40px;
height: 40px;
border-radius: 50%;
cursor: pointer;
font-size: 1.5rem;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s;
z-index: 10;
}
.lightbox-close:hover {
background: rgba(255, 255, 255, 0.3);
transform: scale(1.1);
}
.lightbox-content {
max-width: 90%;
max-height: 90%;
animation: lightboxFadeIn 0.3s ease;
}
.lightbox-content img {
width: 100%;
height: auto;
max-height: 400px;
object-fit: contain;
border-radius: 8px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
@keyframes lightboxFadeIn {
from { opacity: 0; transform: scale(0.9); }
to { opacity: 1; transform: scale(1); }
}
With Caption
HTML
<div class="lightbox-overlay">
<button class="lightbox-close">×</button>
<div class="lightbox-caption-content">
<img src="https://images.unsplash.com/photo-1501785888041-af3ef285b470?w=800" alt="Image">
<div class="lightbox-caption">
<h4 class="lightbox-caption-title">Mountain Landscape</h4>
<p class="lightbox-caption-text">Beautiful mountain view at sunset</p>
</div>
</div>
</div>
CSS
.lightbox-overlay {
position: relative;
width: 100%;
min-height: 450px;
background: rgba(0, 0, 0, 0.9);
display: flex;
align-items: center;
justify-content: center;
padding: 2rem;
border-radius: 8px;
}
.lightbox-close {
position: absolute;
top: 1rem;
right: 1rem;
background: rgba(255, 255, 255, 0.2);
border: none;
color: white;
width: 40px;
height: 40px;
border-radius: 50%;
cursor: pointer;
font-size: 1.5rem;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s;
z-index: 10;
}
.lightbox-close:hover {
background: rgba(255, 255, 255, 0.3);
transform: scale(1.1);
}
.lightbox-caption-content {
max-width: 90%;
max-height: 90%;
animation: lightboxFadeIn 0.3s ease;
display: flex;
flex-direction: column;
align-items: center;
}
.lightbox-caption-content img {
width: 100%;
height: auto;
max-height: 350px;
object-fit: contain;
border-radius: 8px 8px 0 0;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.lightbox-caption {
background: white;
padding: 1.25rem 1.5rem;
border-radius: 0 0 8px 8px;
width: 100%;
text-align: center;
}
.lightbox-caption-title {
margin: 0 0 0.5rem;
font-size: 1.1rem;
font-weight: 700;
color: #1a1a2e;
}
.lightbox-caption-text {
margin: 0;
font-size: 0.9rem;
color: #666;
}
@keyframes lightboxFadeIn {
from { opacity: 0; transform: scale(0.9); }
to { opacity: 1; transform: scale(1); }
}
With Navigation
HTML
<div class="lightbox-overlay">
<button class="lightbox-close">×</button>
<button class="lightbox-nav lightbox-prev">‹</button>
<button class="lightbox-nav lightbox-next">›</button>
<div class="lightbox-content">
<img src="https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05?w=800" alt="Image">
</div>
<div class="lightbox-counter">1 / 5</div>
</div>
CSS
.lightbox-overlay {
position: relative;
width: 100%;
min-height: 450px;
background: rgba(0, 0, 0, 0.9);
display: flex;
align-items: center;
justify-content: center;
padding: 2rem;
border-radius: 8px;
}
.lightbox-close {
position: absolute;
top: 1rem;
right: 1rem;
background: rgba(255, 255, 255, 0.2);
border: none;
color: white;
width: 40px;
height: 40px;
border-radius: 50%;
cursor: pointer;
font-size: 1.5rem;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s;
z-index: 10;
}
.lightbox-close:hover {
background: rgba(255, 255, 255, 0.3);
transform: scale(1.1);
}
.lightbox-nav {
position: absolute;
top: 50%;
transform: translateY(-50%);
background: rgba(255, 255, 255, 0.2);
border: none;
color: white;
width: 50px;
height: 50px;
border-radius: 50%;
cursor: pointer;
font-size: 2rem;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s;
z-index: 10;
}
.lightbox-nav:hover {
background: rgba(255, 255, 255, 0.3);
transform: translateY(-50%) scale(1.1);
}
.lightbox-prev {
left: 1rem;
}
.lightbox-next {
right: 1rem;
}
.lightbox-content {
max-width: 90%;
max-height: 90%;
animation: lightboxFadeIn 0.3s ease;
}
.lightbox-content img {
width: 100%;
height: auto;
max-height: 400px;
object-fit: contain;
border-radius: 8px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.lightbox-counter {
position: absolute;
bottom: 1rem;
left: 50%;
transform: translateX(-50%);
background: rgba(0, 0, 0, 0.7);
color: white;
padding: 0.5rem 1rem;
border-radius: 20px;
font-size: 0.9rem;
font-weight: 600;
}
@keyframes lightboxFadeIn {
from { opacity: 0; transform: scale(0.9); }
to { opacity: 1; transform: scale(1); }
}