jquery向下滚动头部效果

本文介绍了一种使用数据属性和路径点插件实现的滚动触发页面头部动画效果的方法。通过为不同的滚动方向设置特定的类名,可以实现如旋转等丰富的动画效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

下载地址

多种头部展示效果

Header Effects

? Previous Demo Something Anything Back to the article
Dalliance Inglenook Lagniappe Mellifluous Erstwhile Wafture Serendipity Love

我们添加一个特殊的类的部分将触发类变化:

数据atrributes用于设置正确的课程取决于哪个方向滚动。在我们的演示animate-up数据属性包含的类前animate-down。一个状态类的一个例子是“旋转”: .ha-header-rotate { height: 220px; top: 50px; padding-left: 50px; padding-right: 50px;} .ha-header-rotate .ha-header-front { transform: translateY(-100%) rotateX(90deg);} .ha-header-rotate .ha-header-bottom { top: 50%; transition: transform 0.5s; transform: rotateX(0deg) translateY(-100%);}路径点插件的帮助下,只需添加相应的类:var $head = $( "#ha-header" );$( ".ha-waypoint" ).each( function(i) { var $el = $( this ), animClassDown = $el.data( "animateDown" ), animClassUp = $el.data( "animateUp" ); $el.waypoint( function( direction ) { if( direction === "down" && animClassDown ) { $head.attr("class", "ha-header " + animClassDown); } else if( direction === "up" && animClassUp ){ $head.attr("class", "ha-header " + animClassUp); } }, { offset: "100%" } );} );

38_fbfe09d49e3ab131d0ef6a58e7a387e1.jpg

dd:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值