HTML & CSS - Hover state maintained after transition
Simple example for StackOverflow
by Amaury Dalla Monta
HTML
<div id="container">
<div id="content">Hover me !</div>
</div>
CSS
/** The problem **/
#content:hover {
background-color: deepskyblue;
cursor: pointer;
transform:translateY(300px);
-webkit-transform: translateY(300px);
transition: 1s 500ms;
transition-property: transform, background-color;
}
/** Just for fun **/
html, body {
height: 100%;
overflow: hidden;
}
#container {
width: 80%;
height: 80%;
background: beige;
border: 1px solid black;
border-radius: 5px;
margin: 10px auto;
padding: 10px;
}
#content {
display: flex;
align-items: center;
justify-content: center;
width: 100px;
height: 100px;
background: coral;
border: 1px solid black;
border-radius: 5px;
margin: 10px auto;
padding: 10px;
}