HTML & CSS - Hover state maintained after transition
Simple example for StackOverflow
HTML
<div id="container">
<div id="content">Hover me !</div>
<div id="tip">Some tip</div>
</div>
CSS
/** The problem **/
#content:hover {
background-color: deepskyblue;
cursor: pointer;
transform:translateY(300px);
-webkit-transform: translateY(300px);
}
#tip {
display: none;
}
#content:hover + #tip {
display: block;
}
}
/** 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;
transition: 1s 500ms;
transition-property: transform, background-color;
}
JavaScript
var doc = document;
var content = doc.getElementById('content');
content.addEventListener('click', function() {
console.log('click');
});
content.addEventListener('mouseleave', function() {
console.log('leave');
});
content.addEventListener('mouseenter', function() {
console.log('enter');
});