我有一个巨大的图像(2000 像素上的 3000 像素),我想将此图像设置为网站背景并调整图像与窗口的比例。到目前为止,我正在这样做:
body {
background: url('image.jpg') !important;
background-repeat: no-repeat !important;
background-attachment: fixed !important;
background-position: center !important;
}
图像设置在背景上,但并不完全可见 - 只是图像的“中心”,而不是整个图像。
有什么方法可以使用 CSS 来实现吗?
最佳答案
我想你想要这个:
* {
margin: 0px;
padding: 0px;
border: 0px groove;
}
body {
width: 100%;
height: 100%;
background-image: url(picture);
background-size: 100%;
}
关于html - CSS - 如何设置一个巨大的图像到浏览器窗口的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17921937/