jQuery代码部分
$(function(){ var ad = $(".teachers_right_ad"); //声明对象 var ad_f = $(".arc_right"); //对象父元素 var ad_gf = $(".arc_box"); //对象父元素的父元素 var offset = ad.offset(); var box_h = ad.outerHeight(true); var h=ad_gf.offset().top+ad_gf.outerHeight()-box_h; //计算触发ad停止fixed的临界点 var hf=ad_gf.offset().top+ad_gf.outerHeight(); //计算触发ad停止absolute的临界点 var hh=ad_gf.height()-ad.outerHeight(true); //计算adabsolute的top值 ad_f.css({"position":"relative"}); //给定ad的父元素position relative $(window).scroll(function(){ if($(window).scrollTop()>=offset.top&&$(window).scrollTop()=h &&$(window).scrollTop()
当前名称:jQuery实现广告图fixed与scroll关联
链接分享:http://scjiangan.com/article/jhsgij.html