<h1>Gallery with hover effect</h1>
<div class="wrapper">
<div class="media">
<div class="layer">
<p>+ Paul Gilmore</p>
</div>
<img src="https://images.unsplash.com/photo-1431818563807-927945852ab6?dpr=1&auto=format&fit=crop&w=1199&h=899&q=80&cs=tinysrgb&crop=" alt="" />
</div>
<div class="media">
<div class="layer">
<p>+ M. O' Neil</p>
</div>
<img src="https://images.unsplash.com/photo-1443397646383-16272048780e?dpr=1&auto=format&fit=crop&w=1199&h=899&q=80&cs=tinysrgb&crop=" alt="" />
</div>
<div class="media">
<div class="layer">
<p>+ N. Mehta</p>
</div>
<img src="https://images.unsplash.com/photo-1442965416224-f6a7eca980fa?dpr=1&auto=format&fit=crop&w=1199&h=799&q=80&cs=tinysrgb&crop=" alt="" />
</div>
</div>
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@200;400;900");
body {
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background: #e0e0e0;
overflow: hidden;
font-family: "Inter", sans-serif;
}
h1 {
font-size: 22px;
color: #333;
text-align: center;
margin-bottom: 1.4rem;
}
.wrapper {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
flex-wrap: wrap;
gap: 10px;
}
.media {
max-width: 300px;
max-height: 200px;
overflow: hidden;
position: relative;
display: flex;
justify-content: center;
align-items: center;
}
.media img {
max-width: 100%;
height: auto;
}
.layer {
opacity: 0;
position: absolute;
display: flex;
justify-content: center;
align-items: center;
width: 10px;
height: 90%;
background: #fff;
color: #151e3f;
transition: all 0.9s ease;
p {
transition: all 0.9s ease;
transform: scale(0.1);
}
}
p {
text-align: center;
font-size: 15px;
letter-spacing: 1px;
}
.media:hover .layer {
opacity: 0.8;
width: 90%;
transition: all 0.5s ease;
p {
transform: scale(1);
transition: all 0.9s ease;
}
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.