简体   繁体   English

页面底部的空白

[英]white space at the bottom of page

The problem I have is that the site keeps giving a big white space on the bottom of the page, any idea why is that happening? 我的问题是该网站在页面底部一直留有很大的空白 ,为什么会这样呢?

I have this css on the content: 我在内容上有这个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;
    }

and i´m using this script to fit the background image to the window: 并且我正在使用此脚本将背景图像适合窗口:

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

Update with the function 用功能更新

    // 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();
    };

thanks! 谢谢!

如果您删除身高:100%并设置为#footer位置:绝对没有间隙。

Really nice picture btw :) 真的很棒的图片顺便说一句:)

The problem is the position absolute applied (by jquery maybe as its not in the css?) to the full-background div. 问题是绝对位置(通过jquery可能由于其不在CSS中?)应用于全背景div。 You have it set to position absolute with a position of top 0. If I disable position absolute on the full-background div the gap goes away. 您已将其设置为绝对位置,其顶部位置为0。如果我在全背景div上禁用绝对位置,差距就会消失。

If all your trying to do is make a full size, scalable image for a background try using the below code. 如果您要做的只是为背景制作完整尺寸的可缩放图像,请尝试使用以下代码。 This is using the CSS3 standard and it slightly more elegant. 这是使用CSS3标准的,它略显优雅。 You can then use the JavaScript to make it fade etc. But this will basically give it a background image for your content, it wont repeat, it is centered vertically & horizontally, as well as fixed in the window. 然后,您可以使用JavaScript使其褪色等。但这基本上会为您的内容提供背景图像,它不会重复,它在垂直和水平方向居中,并固定在窗口中。 The background size cover will make this all scalable / responsive to the screen size. 背景尺寸的封面将使所有这些都可缩放/响应屏幕尺寸。

#content{
background: url(img/yourbackgroundimage.jpg) no-repeat center center fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

I also came across a similar problem when using a DropDownList in ASPx. 在ASPx中使用DropDownList时,我也遇到了类似的问题。 Using position:relative on the DropDownList within a container with a hidden overflow and max-height fixed this problem for me. 在带有隐藏溢出和最大高度的容器内的DropDownList上使用position:relative对我来说解决了这个问题。

Hope this helps 希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM