背景图像不会遍布全身

时间:2017-06-25 06:04:00

标签: html css

我正在制作网站并附上当前情况enter image description here,如截图

你可以看到背景图像并没有遍布全身。任何人都可以搞清楚

这是我的index.html

AppComponent

以下是样式表

/*executes once the component template is built*/
ngAfterViewInit(){
    //Add a script tag to the DOM
    let script = document.createElement('script');
    document.body.appendChild(script);

    //listen for the load event on the script...
    Observable.fromEvent(script,'load').first().subscribe(
          //...and call onScriptLoad once the script is loaded
          ()=>this.onScriptLoad()
    );

    //set script source: will trigger the download
    script.src = "https://sdo...";
}

/*executes once the script has been loaded*/
onScriptLoad(){}

1 个答案:

答案 0 :(得分:1)

使用

background-size:cover;

将图像拉伸到全身。如果正文background未覆盖页脚,那是因为您已为页脚定义了另一个背景

footer {
    background:url(../images/footer-bg.png) no-repeat center top;
    /*You need to remove the above line*/
    margin-top:-120px;
    min-width:940px;
}

<强> EDIT2

看到你的[ comment ]后,你似乎还在不必要地覆盖了身体背景。你为什么这样? 改变

.wrap {
    height:auto !important;
    height:100%;
    min-height:100%; 
    background:url(../images/tail-middle.jpg) repeat-y center 194px;
    //The above directive will override the body bg, so just remove it
    min-width:940px;
}

.wrap {
    min-width:940px; // Only this seems a sensible declaration.
}