Hover to translate image.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rahul Gupta</title>
<link rel="stylesheet" type="text/css" href="style.css">
<style type="text/css">
*
{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body
{
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.imgBx
{
position: relative;
width: 400px;
height: 500px;
overflow: hidden;
background: url(bg.jpg);
background-size: cover;
}
.imgBx img
{
position: absolute;
top: 0;
bottom: 0;
width: 100%;
height: 100%;
background-size: cover;
transition: 1s;
pointer-events: none;
}
.imgBx:hover img:nth-child(2)
{
opacity: 0;
filter: blur(10px);
transform: translateX(-50%) scaleX(2);
}
.imgBx img:nth-child(1)
{
opacity: 0;
filter: blur(10px);
transform: translateX(50%) scaleX(2);
}
.imgBx:hover img:nth-child(1)
{
opacity: 1;
filter: blur(0px);
transform: translateX(0) scaleX(1);
}
</style>
</head>
<body>
<div class="imgBx">
<img src="boy.png">
<img src="girl.png">
</div>
</body>
</html>