0

私が抱えている問題は、サイトがページの下部に大きな空白を与え続けていることです.なぜそれが起こっているのですか?

私はコンテンツにこの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();
    };

ありがとう!

4

3 に答える 3

0

body height:100% を外して #footer position:absolute にすると隙間がなくなります。

于 2013-02-15T09:46:24.313 に答える
0

ところで本当に素敵な写真:)

問題は、完全な背景の div に絶対位置が適用されることです (jquery によって css にないのでしょうか?)。トップ0の位置で絶対位置に設定しています。フルバックグラウンドdivで絶対位置を無効にすると、ギャップがなくなります。

于 2013-02-15T10:05:28.677 に答える