我有一个页面有一个部分,其中有三个图像从左到右动画,它们的时间轴之间有轻微的重叠。
我试图让动画在垂直滚动 200 像素后开始。
实现此目标的最佳方法是什么?仅 CSS 还是我需要使用 javascript?
最佳答案
用 jQuery 试试这样的东西..
/// you probably want to set this dynamically
var change1 = 200;
$(document).scroll(function() {
// you might need to throttle the listener
if (Math.random() < 0.15) {
if( $(this).scrollTop() > change1) {
updateCSS(var);
}}})
function updateCSS(var) {
$image1.css({attribute: x);
$image2.css({attribute: y);
$image3.css({attribute: z);
}
关于javascript - 如何在滚动某些像素后触发CSS动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26048601/