Gallery · 18 of 33
Slide Behind
Image slides to reveal text behind
<div class="slide-behind">
<div class="img-front">
<img src="https://picsum.photos/id/111/800/600" alt="Car">
</div>
<div class="img-back">
<h3>Vintage</h3>
</div>
</div>
.slide-behind {
position: relative;
width: 400px;
aspect-ratio: 4 / 3;
overflow: hidden;
border-radius: 12px;
background: #7c5cff;
}
.img-front {
position: absolute;
top: 0; left: 0;
width: 100%; height: 100%;
transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
z-index: 2;
}
.img-front img {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
}
.img-back {
position: absolute;
top: 0; left: 0;
width: 100%; height: 100%;
display: flex;
align-items: center;
justify-content: center;
z-index: 1;
}
.img-back h3 {
font-family: system-ui, sans-serif;
font-size: 2rem;
color: #fff;
margin: 0;
}
.slide-behind:hover .img-front {
transform: translateX(60px) translateY(-40px) scale(0.8);
}