Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.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 CSS-如何将一个巨大的图像设置为浏览器窗口的大小?_Html_Css_Image_Background_Position - Fatal编程技术网

Html CSS-如何将一个巨大的图像设置为浏览器窗口的大小?

Html CSS-如何将一个巨大的图像设置为浏览器窗口的大小?,html,css,image,background,position,Html,Css,Image,Background,Position,我有一个巨大的图像(3000px对2000px),我想把这个图像作为网站的背景,并调整图像到窗口的比例。到目前为止,我正在这样做: body { background: url('image.jpg') !important; background-repeat: no-repeat !important; background-attachment: fixed !important; background-position: center !important

我有一个巨大的图像(3000px对2000px),我想把这个图像作为网站的背景,并调整图像到窗口的比例。到目前为止,我正在这样做:

body {
    background: url('image.jpg') !important;
    background-repeat: no-repeat !important;
    background-attachment: fixed !important;
    background-position: center !important;
}
图像设置在背景上,但它不是完全可见的-只是图像的“中心”,而不是整个图像


使用CSS有什么办法吗?

使用
背景大小:100%

另外,供进一步参考。

我想您需要这个:

* {
margin: 0px;
padding: 0px;
border: 0px groove;
}
body {
width: 100%;
height: 100%;
background-image: url(picture);
background-size: 100%;
}

您可以在css中执行以下操作

html
{
height:100%;
width:100%;
}

body{
margin:0px;
padding:0px;
height:100%;
width:100%;
background-image: url(picture);
}  
删除任何边距或填充,并将正文设置为“满”

仅使用html页面执行此操作

<html>
<body background="bgimage.jpg" style="height:100%; width:100%;">
<h1>Hello world!</h1>

</body>
</html> 

你好,世界!
请参见下面的示例

使用背景尺寸:100%;回答您的问题后,请单击复选框。