Jquery窗口调整大小不断增加div的高度

时间:2014-06-04 19:02:47

标签: jquery

我目前正在开发一个带有div的网站,需要使用背景图片来增加和减少。

我现在使用的js工作得很好,除非调整窗口大小时它继续增加高度像素。

   $(document).ready(function() {
        $('.content-repeat').each(function(){
            var parentHeight = $(this).parent().height();  
            $(this).innerHeight(function(i,x){
            return x + parentHeight -284+'px';
            });
            $(this).css('margin-top',-parentHeight +170+'px');
            $(this).css('margin-bottom',-170+'px');
        })
        $(window).on('resize', function(){
        $('.content-repeat').each(function(){
            var parentHeight = $(this).parent().height();  
            $(this).innerHeight(function(i,x){
            return x + parentHeight -284+'px';
            });
            $(this).css('margin-top',-parentHeight +170+'px');
            $(this).css('margin-bottom',-170+'px');
        })  
        })
    });

您对如何解决此问题有什么建议吗?

0 个答案:

没有答案
相关问题