$(window).load(function() { $('#slider').nivoSlider({ controlNav:false, effect:'fade', //Specify sets like: 'fold,fade,sliceDown' animSpeed:500, //Slide transition speed captionOpacity:0.9, directionNav:true, //Next & Prev controlNav:true, // 1,2,3... navigation pauseTime: 3000, // How long each slide will show directionNavHide: true, pauseOnHover:true //Stop animation while hovering }); }); $(function() { moveDiv(); //页面初始化执行 $(window).scroll(function(){ moveDiv(); }); }); //右侧居中 function moveDiv() { var scrollTop = $(document).scrollTop(); //滚动条上端隐藏的高度 var clientHeight = $(window).height(); //网页内容区高度 var clientWidth = $(window).width(); //网页内容区高度 //设置位置为 var hei = $("#div_nav_zone_right").css("top"); hei = hei.replace("px",""); var newPosY = scrollTop + 120; $("#div_nav_zone_right").css("top",newPosY+"px"); if(clientWidth<=1320) { $("#div_nav_zone_right").css("right","0px"); }else { if((((clientWidth-1000)/2)-200 )<0) { $("#div_nav_zone_right").css("right","0px"); }else { $("#div_nav_zone_right").css("right",((clientWidth-1000)/2)-200+"px"); } } }