I assume that your popup is absolutely positioned, so you can do the following:
- While hidden, set the
top popup to a huge negative value. This moves it off the screen and eliminates the scroll bar. - In hover mode, set
top to the correct value and move the opacity value. - Make sure your CSS
transition rules are only for the opacity property.
HTML
<a href="">Popup go now</a> <div class="popup"> My cat breath smells like cat food... </div>
CSS
.popup { position: absolute; top: -2000px; opacity: 0; transition: opacity 1s ease-in-out; } a:hover + .popup, .popup:hover { top: 30px; opacity: 1; }
Here is the above in action .
Update. To add a left turn and clear the mouse animation, you can use the following code:
.popup { position: absolute; top: -2000px; width: 300px; left: 0; opacity: 0; transition-property: opacity, left, top; transition-duration: 1s, 1s, 0s; transition-delay: 0s, 0s, 1s; } a:hover + .popup, .popup:hover { top: 30px; left: 30px; opacity: 1; transition-delay: 0s; }
He does it as follows:
- Animation for several properties is set (opacity, left, top).
transition-delay prevents the upper value from changing until the opacity and left animations are complete. The trick here is that when the element is :hover , there is no delay (opacity, left and top animations start immediately). However, as soon as :hover no longer active, the top animation waits 1 second before starting. This gives opacity and leaves enough time to complete.
Here's an updated example .
source share