Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/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
Html 全屏背景_Html_Css - Fatal编程技术网

Html 全屏背景

Html 全屏背景,html,css,Html,Css,我希望我的背景图像在浏览器窗口中完全填充。我试过css body {background:url(bg.jpg) fixed no-repeat 100%} 但它并没有覆盖整个屏幕。我使用backstretch.js将背景与窗口大小相匹配。很明显,它是jquery,但根据我的经验,它非常可靠 我使用backstretch.js使背景适合窗口大小。很明显,它是jquery,但根据我的经验,它非常可靠 为img标签和以下格式创建一个id #background { position: absolu

我希望我的背景图像在浏览器窗口中完全填充。我试过css

body {background:url(bg.jpg) fixed no-repeat 100%}

但它并没有覆盖整个屏幕。

我使用backstretch.js将背景与窗口大小相匹配。很明显,它是jquery,但根据我的经验,它非常可靠


我使用backstretch.js使背景适合窗口大小。很明显,它是jquery,但根据我的经验,它非常可靠


为img标签和以下格式创建一个id

#background {
position: absolute;
left: 0%;
top: 0%;
width: 100%;
height: 100%;
z-index: 1;
}

为img标记和以下格式创建一个id

#background {
position: absolute;
left: 0%;
top: 0%;
width: 100%;
height: 100%;
z-index: 1;
}
CSS:

background: url(yourImage) no-repeat center center fixed;
background-size: cover;
这将固定(固定)图片并将其拉伸。

CSS:

background: url(yourImage) no-repeat center center fixed;
background-size: cover;
css: 
background-size: cover;
这把画钉住(固定)并把它拉长

css: 
background-size: cover;
我想这就是你要找的。 要获得cross borswer支持,请尝试以下方法: CSS:

资料来源:

我想这就是你要找的。 要获得cross borswer支持,请尝试以下方法: CSS:

资料来源:

如果您想要跨浏览器,包括IE,请尝试以下方法:

        theWindow.resize(function() {
            resizeBg();
        }).trigger("resize");

csstricks中也提到了这一点:


如果您想要跨浏览器,包括IE,请尝试以下方法:

        theWindow.resize(function() {
            resizeBg();
        }).trigger("resize");

csstricks中也提到了这一点: