<div class="image">
<img src="https://img4.goodfon.ru/wallpaper/nbig/5/6e/abstrakitsiia-fon-polosy-cherno-krasnyi-tsvet.jpg" alt="">
<div class="image-switch">
<div class="image-switch-item">
<div class="switched-image">
<img src="https://img4.goodfon.ru/wallpaper/nbig/5/6e/abstrakitsiia-fon-polosy-cherno-krasnyi-tsvet.jpg" alt="">
</div>
</div>
<div class="image-switch-item">
<div class="switched-image">
<img src="https://uwalls.ru/gallery/5/source/29577.jpg" alt="">
</div>
</div>
<div class="image-switch-item">
<div class="switched-image">
<img src="https://i.ytimg.com/vi/BwBhaQoiV94/maxresdefault.jpg" alt="">
</div>
</div>
</div>
</div>
.image {
position: relative;
width: 500px;
height: 400px;
margin: 0 auto;
overflow: hidden;
transition: all 0.3s ease-in-out;
}
.image-switch {
position: absolute;
left: 0;
top: 0;
z-index: 20;
width: 100%;
height: 100%;
display: flex;
opacity: 0;
transition: all 0.3s ease-in-out;
}
img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}
.image-switch-item {
width: 33.33%;
transition: all 0.3s ease-in-out;
cursor: pointer;
display: flex;
flex-direction: column;
justify-content: flex-end;
padding-bottom: 5px;
}
.image-switch-item::after {
content: "";
width: 90%;
margin: 0 auto;
height: 3px;
background-color: rgba(255,255,255, 0.4);
border-radius: 10px;
z-index: 2;
position: relative;
transition: all 0.3s ease-in-out;
}
.switched-image {
position: absolute;
left: 50%;
top: 0;
opacity: 0;
z-index: 2;
transition: all 0.3s ease-in-out;
width: 100%;
height: 100%;
transform: translateX(-50%);
pointer-events: none;
}
.image:hover .image-switch {
opacity: 1;
transition: all 0.3s ease-in-out;
}
.image-switch-item:hover .switched-image {
transition: all 0.3s ease-in-out;
opacity: 1;
z-index: -1;
}
.image-switch-item:hover::after {
background-color: #fff;
transition: all 0.3s ease-in-out;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.