【发布时间】:2018-10-04 19:14:21
【问题描述】:
我正在使用 jquery,以便每次用户将鼠标悬停在缩略图/视频上时文本都会淡入。如果用户慢慢将鼠标悬停在项目上,效果会很好,并且文本会在图像上淡入淡出。但是,如果用户在多张图片上快速移动屏幕上的光标,文本会在网站标题中闪烁,而不是在图片中。
这是网站的链接: https://sulemankhalid.com/home.html
HTML 示例:
<a href="animation.html">
<div class="cell" id="animation">
<div id="video-container" style="z-index: -1;">
<video autoplay loop muted style="width: 100%; height:100%;">
<source id="mp4" src="https://sulemankhalid.com/thumbnails/animation.mp4" type="video/mp4">
</video>
</div>
<div class="info">
<h2>Animation &</h2>
<h2>Motion Graphics</h2>
<p>Shion Uino left Sushi Saito, a restaurant many consider to be one of the best in the world, to chart his own path in New York.</p>
</div>
</div>
</a>
Jquery 示例:
$("#animation h2").hide();
$("#animation p").hide();
$("#animation").hover(function(){
$("#animation h2").fadeIn(400);
$("#animation p").fadeIn(400);
$("#animation video").fadeTo("slow", 0.1);
}, function(){
$("#animation h2").fadeOut(400);
$("#animation p").fadeOut(400);
$("#animation video").fadeTo("slow", 1);
});
不胜感激
【问题讨论】:
-
不使用 javascript 来实现这些效果,研究 css3 转换可能对您有所帮助。
标签: javascript jquery html