I have a div which is supposed to appear only on hover. But the animation appears also when I load the page. I want the animated div to be hidden until I hover over the other div. Is there a way to prevent the animation from running when the page is loaded?
Here is the CSS:
#dim {
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
background: rgba(200, 200, 200, 0.8);
z-index:100;
padding: 5%;
animation: fadeout 1s;
animation-fill-mode: forwards;
}
#dim:hover{
animation: fadein 1s;
animation-fill-mode: forwards;
}
/* Animations */
@keyframes fadein {
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes fadeout {
from { opacity: 1; }
to { opacity: 0; }
}
And here is a CodePen: https://codepen.io/Martin36/pen/gWwmZO