I've set up a basic photo carousel, but am having problems getting captions to show embedded on the photos. Here is the code I used:
.container-tutorial {
padding: 2rem;
}
.slider-wrapper-tutorial {
position: relative;
max-width: 48rem;
margin: 0 auto;
}
.slider-tutorial {
display: flex;
aspect-ratio: 16 / 9;
overflow-x: hidden;
scroll-snap-type: x mandatory;
scroll-behavior: smooth;
box-shadow: 0 1.5rem 3rem -0.75rem hsla(0, 0%, 0%, 0.25);
border-radius: 0.5rem;
}
.slider-tutorial img {
flex: 1 0 100%;
scroll-snap-align: start;
object-fit: cover;
}
.slider-nav-tutorial {
display: flex;
column-gap: 1rem;
position: absolute;
bottom: 1.25rem;
left: 50%;
transform: translateX(-50%);
z-index: 1;
}
.slider-nav-tutorial a {
width: 0.5rem;
height: 0.5rem;
border-radius: 50%;
background-color: black;
opacity: 0.75;
transition: opacity ease 250ms;
}
.slider-nav-tutorial a:hover {
opacity: 1;
}
<section class="container">
<div class="slider-wrapper">
<div class="slider">
<img id="slide-1" src="image1.jpg" alt="Image 1">
<figcaption>Image 1 Caption Here</figcaption>
<img id="slide-2" src="image2.jpg" alt="Image 2">
<figcaption>Image 3 Caption Here</figcaption>
<img id="slide-3" src="image3.jpg" alt="Image 3">
<figcaption>Image 3 Caption Here</figcaption>
</div>
<div class="slider-nav">
<a href="#slide-1"></a>
<a href="#slide-2"></a>
<a href="#slide-3"></a>
</div>
</div>
</section>