Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery调整大小计算故障_Jquery_Width_Window Resize - Fatal编程技术网

Jquery调整大小计算故障

Jquery调整大小计算故障,jquery,width,window-resize,Jquery,Width,Window Resize,我设置了一个jQuery宽度计算来调整窗口的大小,这一切都很好,但我发现当我调整大小和拉伸时,会出现“小故障”或分裂秒,其中容器的宽度不同,它们重叠并留下很大的间隙。我理解这是因为jQuery正在执行它的计算,但这是正常的吗 if ($("#Grid").css("margin-bottom") === "1px") { oneCol(); } if ($("#Grid").css("margin-bottom") === "0px") { twoCol(); } funct

我设置了一个jQuery宽度计算来调整窗口的大小,这一切都很好,但我发现当我调整大小和拉伸时,会出现“小故障”或分裂秒,其中容器的宽度不同,它们重叠并留下很大的间隙。我理解这是因为jQuery正在执行它的计算,但这是正常的吗

if ($("#Grid").css("margin-bottom") === "1px") {
    oneCol();
}

if ($("#Grid").css("margin-bottom") === "0px") {
    twoCol();
}

function oneCol () {
    $('#middle').hide();
    $('#Grid').css('width', '100%').css('width', '-=170px');
}

function twoCol() {
    $('#middle').show();

    $('#middle').outerWidth(function () {
        return ($(this).parent().width() * 0.5) - $('#left').outerWidth() / 2;
    });

    $('#Grid').outerWidth(function () {
        return ($(this).parent().width() * 0.5) - $('#left').outerWidth() / 2;
    });
}


$(window).on('resize', function () {
    if ($("#Grid").css("margin-bottom") === "1px") {
        oneCol();
    }

    if ($("#Grid").css("margin-bottom") === "0px") {
        twoCol();
    }
});

这是我的名片

好的,我在Chrome上看到了更多的小故障。不确定是否可以完全消除它,但通过优化大小调整例程,它看起来好多了:

function oneCol () {
    $('#middle').hide();
    $('#Grid').width( $(window).width() - $('#left').outerWidth() );
}

function twoCol() {
    $('#middle').show();
    var w = ($(window).width() - $('#left').outerWidth())/2;
    $('#middle').width(w);
    $('#Grid').width(w);
 }


$(window).on('resize', function () {
    if ($(window).width()<100) {
        oneCol();
    } else {
        twoCol();
    }
});
函数oneCol(){ $(“#中间”).hide(); $('网格').width($(窗口).width()-$('左').outerWidth()); } 函数twoCol(){ $(“#中间”).show(); var w=($(窗口).width()-$('#左').outerWidth())/2; $('中间')。宽度(w); $('网格')。宽度(w); } $(窗口).on('resize',函数(){
if($(window).width()我在调整大小时没有发现问题:这个浏览器是特定的吗?如果是,它出现在哪个浏览器上?我正在Chrome上查看。