jQuery广告跟随滚动的两种方法都分享给大家,希望对大家的学习有所启发。
方法一:
方法二:
/*页面智能层浮动*/
jQuery(document).ready(function($){
var $sidebar = $(".float"),
$window = $(window),
offset = $sidebar.offset(),
topPadding = 20;
$window.scroll(function() {
if ($window.scrollTop() > offset.top) {
$sidebar.stop().animate({
marginTop: $window.scrollTop() - offset.top + topPadding
});
} else {
$sidebar.stop().animate({
marginTop: 0
});
}
});
});
博主推荐
广告代码
以上就是jQuery网页右侧广告跟随滚动,仿wordpress右侧广告跟随滚动,希望对大家的学习有所帮助。