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

标签 html css image background position

我有一个巨大的图像(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/

相关文章:

html - 在经典 asp 中发送邮件时出现 URL 问题

javascript - 从表内的下拉列表中获取选定的值

产品上的 CSS 收据自动换行

html - Bootstrap 在列之间添加空间

image - 使用Jenkins docker镜像无法连接github

jquery - 外部页面在刷新时消失 - jquery mobile

javascript - keydown 事件是如何工作的?

javascript - JQuery 不将 css 应用于选定的 li

javascript - 如何在 AngularJS/Jasmine 单元测试中模拟图像加载事件?

python - 我如何使用 Python 缩略图