I can not understand how to return the block to its original state to make it smooth. How to do with html and css, without js.
.button { display: block; position: fixed; height: 100px; width: 100px; bottom: 50px; border: 1px solid black; } .block { display: block; position: fixed; height: 100px; width: 100px; top: 50px; border: 1px solid #aaa; color: #aaa; } .button.one { margin: 0 30%; } .button.two { margin: 0 50%; } .button.tree { margin: 0 70%; } .block.one { margin: 0 30%; } .block.two { margin-left: 50%; } .block.tree { margin-left: 70%; } span { position: absolute; top: 40%; left: 23%; } input { display: none; } label { position: absolute; top: 0%; left: 0%; height: 100px; width: 100px; } .spanBlock { position: absolute; top: 40%; left: 46%; } /* Connecting animation*/ .button.one:hover+.block.one { animation: one 2s forwards; } input:checked+.block.two { animation: two 2s forwards; } .button.tree:active+.block.tree { animation: tree 2s forwards; } /* End сonnecting animation*/ /* Animation button*/ .button.one:hover { background: #bbb; transition: 1s; } input:checked+div+div { background: #bbb; transition: 1s; } .button.tree:active { background: #bbb; transition: 1s; } /* End animation button*/ @keyframes one { 0% { transform: translateY(0px); border: 1px solid #aaa; color: #aaa; } 100% { transform: translateY(150px) rotate(45deg); border: 1px solid black; color: black; } } @keyframes two { 0% { transform: translateY(0px); border: 1px solid #aaa; color: #aaa; } 100% { transform: translateY(200px); border: 1px solid black; color: black; } } @keyframes tree { 0% { transform: translateX(0px); } 100% { transform: translateX(400px); } } <div class="button one"><span>Hover me</span></div> <div class="block one"><span class="spanBlock">1</span></div> <input id="ch" type="checkbox"> <div class="block two"><span class="spanBlock">2</span></div> <div class="button two"> <label for="ch"> <span>Click me</span> </label> </div> <div class="button tree"><span>Hold me</span></div> <div class="block tree"><span class="spanBlock">3</span></div>
transitionusually not set to the active element, but to the normal one, so that smoothness works in both directions - DaemonHK