简体   繁体   English

逐渐为 SVG 设置动画

[英]Animate SVGs gradually

How can I solve this.我该如何解决这个问题。 I need to animate on hover a div that contains two svgs or imgs, nevermind.我需要在 hover 上制作一个包含两个 svg 或 img 的 div,没关系。 How can i trigger that when I hover inside of that div, the two imgs will eg move.当我在该 div 内 hover 时,我如何触发它,这两个 imgs 将例如移动。 Maybe with Javascript, but I can seem to target the img when on hover.也许使用 Javascript,但我似乎可以在 hover 上瞄准 img。 There is only mouseover?只有鼠标悬停? which leaves the state changed forever.这使得 state 永远改变了。 I need help.我需要帮助。 Thank you!谢谢!

<div class="circle">
<img id="line-1" src="line.svg" alt="line">
<img id="line-2" src="line.svg" alt="line">
<div>
.circle {
  position: relative;
  height: 150px;
  width: 150px;
  border: 6px solid black;
  border-radius: 50%;
  padding: 10px;
}

#line-1 {
positin: absolute;
left: 0;
animation: slide 1s ease-in infinite;}

#line-2 {
positin: absolute;
right: 0;
animation: slide-otherway 1s ease-in infinite;}

@keyframes slide {
   0% {
left: 0;
}

100% {
left: 20px;
}
}

@keyframes slide-otherway {
   0% {
right: 0;
}

100% {
right: 20px;
}
}

with mouseenter u also need to use mouseleave, mouseleave will trigger when ofc, the muse leaves用mouseenter你还需要使用mouseleave,mouseleave会在ofc时触发,muse离开

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM