javascript - 在另一个元素悬停时停止动画

标签 javascript jquery html css

我想在悬停左键时停止。

这是我的代码:https://codepen.io/anon/pen/rpQoKz

我的幻灯片不会停止在我最后的样式规则 #container:has(#carousel-left:hover) > .photobanner

我读过它可能不存在并尝试使用 :has 选择器 post about :has selector .感谢您的帮助。

最佳答案

你需要像这样改变你的html

 <div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
<div id="container">
   <a class="left carousel-control" id="carousel-left" href="#carousel-example-generic" role="button" data-slide="prev">
        <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
        <span class="sr-only">Previous</span>
    </a>
    <a class="right carousel-control" id="carousel-right" href="#carousel-example-generic" role="button" data-slide="next">
         <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
         <span class="sr-only">Next</span>
    </a>
    <div class="photobanner">
        <img class="first-image active" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/13034/sticker.png" alt="" />
        <img src="https://designshack.net/tutorialexamples/photobanner/image-3.jpg" alt="" />
        <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/13034/sticker.png" alt="" />
        <img src="https://designshack.net/tutorialexamples/photobanner/image-3.jpg" alt="" />
        <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/13034/sticker.png" alt="" />
        <img src="https://designshack.net/tutorialexamples/photobanner/image-3.jpg" alt="" />
        <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/13034/sticker.png" alt="" />
        <img src="https://designshack.net/tutorialexamples/photobanner/image-3.jpg" alt="" />
        <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/13034/sticker.png" alt="" />
        <img src="https://designshack.net/tutorialexamples/photobanner/image-3.jpg" alt="" />
    </div>
</div>
  </div>

</div>

和CSS

#carousel-left:hover ~ .photobanner{
    animation-play-state: paused;
}

关于javascript - 在另一个元素悬停时停止动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48325830/

相关文章:

php - 为什么标签标题,元标签会自动从头标签转到 body 标签

php - jQuery $.post 不显示第二次更改的数据

javascript - JQuery load() 第一次没有加载页面

javascript - 阻止表单重定向?

PHP 还是 JS 模板引擎? (对于同一 html 的多个 block )

javascript - 如何在 jstree 更改事件中获取更改项目的 id

javascript - 如何访问 DIV 的 innerHTML onclick(ng-click)Angular JS 中的按钮

javascript - 在react中将多个JSON结果渲染到HTML列表

Javascript 无法在另一个函数内调用数组推送

jquery - icheck 复选框不适用于 angularjs