The essence of the question is this. Animation works fine when hover, but when I move the cursor away, there is not a smooth transition, but a sharp one. I can not understand what is wrong. You need a smooth transition when you hover and when the cursor is removed from the element. Thank!
.div1 { width: 200px; height: 200px; background: #ccc; position: relative; } @keyframes work-view { 0% { top: 0; } 100% { top: calc(45% - 25px); } } @keyframes work-opacity { 0% { opacity: 0; } 100% { opacity: 0.8; } } .div1:hover { background: #fcdc21; animation: work-opacity 0.3s ease; } .div1:hover:after { content: "+"; font-size: 50px; color: #282828; position: absolute; bottom: 0; left: calc(50% - 15px); right: 0; top: calc(45% - 25px); z-index: 1; animation: work-view 0.5s ease-in-out; } <div class="div1"></div>