JSFiddle - React, Tailwind, and code Playground
HTML
<div class="a">
<div class="b"></div>
<div class="c">1</div>
<div class="c">2</div>
<div class="c">3</div>
</div>
CSS
.a {
width: 90px;
height: 30px;
position: relative;
}
.b {
width: 30px;
height: 30px;
background: red;
position: absolute;
transition: 0.3s ease left;
left: 0;
}
.c {
width: 30px;
height: 30px;
border: 1px solid black;
box-sizing: border-box;
cursor: pointer;
float: left;
position: relative;
text-align: center;
line-height: 28px;
}
JavaScript
$('.c').on('click', function(){
$('.b').css({
left: $(this).position().left
});
});