我目前正在开发一个带有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');
})
})
});
您对如何解决此问题有什么建议吗?