Ich habe ein div in dem sich ein anderes div bewegt. Ich muss .block
an der aktuellen Position stoppen, wenn ich auf .container
schweben. Wie es geht?Wie stoppe CSS Animation in der aktuellen Position bei Hover?
HTML:
<div class="container">
<div class="block"></div>
</div>
CSS:
.container {
width: 200px;
height: 100px;
padding: 10px;
border: 1px solid #000;
position: relative;
}
.block {
width: 100px;
height: 100px;
background: red;
position: absolute;
animation: move 2s linear infinite;
}
@keyframes move {
0% { left: 10px; }
25% { left: 50px; }
50% { left: 100px; }
75% { left: 50px; }
100% { left: 10px; }
}
Es ist so einfach. Vielen Dank! –