I faced the problem that when you hover on a div, the h4 embedded in it should move to the left, and when you remove the mouse, you will have to return back smoothly. The beginning of the animation works norms, but back a sharp jump back, how can this be fixed?
.wrapper { width: 250px; height: 250px; background: orange; margin: 0 auto; position: relative; } .wrapper h4 { width: 100%; text-align: center; position: absolute; top: 25%; } .wrapper:hover h4 { -webkit-animation: head .5s; animation: head .5s; -webkit-animation-fill-mode: forwards; animation-fill-mode: forwards; } @keyframes head { from { right: 0; } to { right: 35%; } } <div class="wrapper"> <h4>Hello</h4> </div>