javascript - 页面底部的空白

标签 javascript jquery html css

我遇到的问题是该网站一直在页面底部提供大空白,知道为什么会这样吗?

我在内容上有这个 css:

    #content{
        width: 990px;
        margin: 0 auto;
        min-height: 100%;
        height: auto !important;
        height: 100%;
        margin: 0 auto -40px;
        position: relative;
    }

    .full-background {
        z-index: -999;
        min-height: 100%;
        min-width: 1024px;
        width: 100%;
        height: 100%;
        position: fixed;
        top: 0;
        left: 0;
    }

我正在使用此脚本使背景图像适合窗口:

    function fittobox(){
        $('.fittobox').each(function(){
            $(this).fitToBox();
        })
    }
    $(window).bind({
        'load' : fittobox,
        'resize' : fittobox
    })

用函数更新

    // fitToBox
    jQuery.fn.fitToBox =
    function(){
        var div = this.parent();
        var img = this;
        var imAR = img.attr("height") / img.attr("width");
        var bgAR = div.height() / div.width();
        if(imAR >= bgAR){
            img.attr("width" , div.width());
            img.attr("height" , div.width() * imAR);
        }else{
            img.attr("height" , div.height());
            img.attr("width" , div.height() / imAR);
        }
        div.css({
            "position" : "absolute",
            "overflow" : "hidden"
        });
        img.css({
            "position" : "absolute",
            "left" : (div.width() - img.attr("width"))/2,
            "top" : (div.height() - img.attr("height"))/2
        });
        img.fadeIn();
    };

谢谢!

最佳答案

如果删除 body height:100% 并设置 #footer position:absolute 则不会有间隙。

关于javascript - 页面底部的空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14891775/

相关文章:

javascript - 使用 PHP 对 unicode 字符进行转义

javascript - 根据某些情况禁用 div

javascript - 无法使用 Laravel Blade 堆栈运行 JS 代码

没有回调的 jQuery 动画顺序

javascript - 在 javascript/jquery 中读取/更新数组对象的数组

html - 图像顶部的 Bootstrap 面板

javascript - 使用 AngularJS 实现本地存储

javascript - 调整输入文本区域的大小

javascript - JQuery Children().find(x) 返回错误结果 - prevObject

html - Bootstrap 4 - 如何使文本彼此处于相对位置?