JSFiddle - React, Tailwind, and code Playground
by luka kupunia
HTML
<div class="box">
<img src="https://i.picsum.photos/id/89/1000/500.jpg" alt="">
</div>
CSS
body {
margin: 0;
overflow: hidden;
}
.box {
width: 100%;
height: 100vh;
position: relative;
background: red;
overflow: hidden;
border-radius: 50px;
transform: translate(-90%,0);
transition: 1s;
}
.box img {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
object-fit: cover;
transform: translate(50%,0);
transition: 1s;
}
.box.active {
transform: translate(0,0);
}
.box.active img{
transform: translate(0,0);
}
JavaScript
$('.box').click(function(){
$(this).toggleClass('active')
})