Html CSS-如何将一个巨大的图像设置为浏览器窗口的大小?
我有一个巨大的图像(3000px对2000px),我想把这个图像作为网站的背景,并调整图像到窗口的比例。到目前为止,我正在这样做: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
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%;回答您的问题后,请单击复选框。