Hover or focus the image to see the effect.
HTML
CSS
.hover-effect.horizontal-split{
position: relative;
display: block;
overflow: hidden;
}
.hover-effect.horizontal-split::before,
.hover-effect.horizontal-split::after{
content: "";
position: absolute;
top: 0;
bottom: 0;
width: 50%;
pointer-events: none;
transition: transform 0.5s ease;
}
.hover-effect.horizontal-split::before{
left: 0;
background: rgba(15, 23, 42, 0.85);
transform: translateX(0);
}
.hover-effect.horizontal-split::after{
right: 0;
background: rgba(15, 23, 42, 0.85);
transform: translateX(0);
}
.hover-effect.horizontal-split:hover::before,
.hover-effect.horizontal-split:focus-visible::before{
transform: translateX(-100%);
}
.hover-effect.horizontal-split:hover::after,
.hover-effect.horizontal-split:focus-visible::after{
transform: translateX(100%);
}
Two pseudo-elements, each 50% wide, slide apart in opposite directions on hover/focus, revealing the image as the overlay splits horizontally. Select the code and copy with Ctrl+C or ⌘C.