$(function () { if ($(window).width() >= 990) { function bianhua() { var right_width = $(".news_detail01 .c_left").width();//鍙充晶瀵艰埅瀹藉害 lwidth(right_width); $(window).scroll(function () { lwidth(right_width); }); }; function bianhua2() { var right_width = $(".news_detail01 .article_article_fr ").width();//鍙充晶瀵艰埅瀹藉害 rwidth(right_width); $(window).scroll(function () { rwidth(right_width); }); }; bianhua(); bianhua2(); } $(window).resize(function() { var left_width = $(".news_detail01 .c_left").width();//鍙充晶瀵艰埅瀹藉害 var right_width = $(".news_detail01 .article_article_fr ").width();//鍙充晶瀵艰埅瀹藉害 lwidth(left_width); rwidth(right_width); }); }) function lwidth(right_width){ var leftTop = $(".news_detail01 .content").offset().top; var rightTop = $(".news_detail01 .c_left").offset().top; var _top = $('.heig_load').height(); var scrollerTop = $(this).scrollTop() + _top; if (scrollerTop > leftTop) { var vWidth=$(window).width(); var vBoxWidth=$(".news_detail01 .content").width(); var vLeftWidth=$(".news_detail01 .article_article_fl").outerWidth(); var resuLeft=(vWidth-vBoxWidth)/2; var _top = $("header").height() + $(".heig_load").height(); if(vWidth<=1200){ _top = 106+34; } if(vWidth<=1007){ _top = 80; } if (scrollerTop + $(".news_detail01 .c_left").height() < $(".news_detail01 .content .c_center").height()) { $(".news_detail01 .c_left").css({ "position": "fixed", "left":resuLeft + "px", "top": _top, "width": right_width }); } else { if ($(".news_detail01 .c_left").height() > $(".news_detail01 .content .box").height()) { $(".news_detail01 .c_left").css({ "position": "static", "left": "inherit", 'left': '0', 'top': 0 }); } else { $(".news_detail01 .c_left").css({ "position": "absolute", "left": 0, "top": (_top - (scrollerTop + $(".news_detail01 .c_left").height() - (leftTop + $(".news_detail01 .content .box").height()))) + "px", "width": right_width }); } } } else { if ($(".news_detail01 .c_left").css("position") != "absolute") { $(".news_detail01 .c_left").css({ "position": "absolute", "left": "inherit", 'left': '0', 'top': 0 }); } } } function rwidth(right_width){ var vWidth=$(window).width(); var leftTop = $(".news_detail01 .content").offset().top; var rightTop = $(".news_detail01 .c_right").offset().top; var _top = $("header").height() + $(".heig_load").height(); if(vWidth<=1200){ _top = 106+34; } if(vWidth<=1007){ _top = 80; } var scrollerTop = $(this).scrollTop() + _top; if (scrollerTop > leftTop) { var vBoxWidth=$(".news_detail01 .content").width(); var vLeftWidth=$(".news_detail01 .article_article_fl").outerWidth(); var resuLeft=(vWidth-vBoxWidth)/2+vLeftWidth+15; if (scrollerTop + $(".news_detail01 .c_right").height() < leftTop + $(".news_detail01 .content .c_center").height()) { $(".news_detail01 .c_right").css({ "position": "fixed", "left": resuLeft + "px", "top": _top }); } else { if ($(".news_detail01 .c_right").height() > $(".news_detail01 .article_article_fl ").height()) { $(".news_detail01 .c_right").css({ "position": "static", "left": "fixed", 'right': 0, 'top': 0 }); } else { $(".news_detail01 .c_right").css({ "position": "absolute", "left": "15px", "top": (_top - (scrollerTop + $(".news_detail01 .c_right").height() - (leftTop + $(".news_detail01 .content .box").height()))) + "px" }); } } } else if ((scrollerTop < leftTop)) { if ($(".news_detail01 .c_right").css("position") != "absolute") { $(".news_detail01 .c_right").css({ "position": "static", "left": "fixed", 'right': '0', 'top': 0 }); } } }