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,我想有一个全宽的背景,但当我使用背景尺寸:封面时,它的一部分被剪掉了。如果背景大小为:contain,它将在右侧重复。 是否可以在不裁剪、调整大小或重复的情况下获得完整尺寸 CSS: 你试过这个吗 body { background-image: url("https://imgur.com/a/r9JRp"); background-position: center top; background-size: 100% auto; } 试试这个 将背景大小设置为“覆盖

我想有一个全宽的背景,但当我使用背景尺寸:封面时,它的一部分被剪掉了。如果背景大小为:contain,它将在右侧重复。 是否可以在不裁剪、调整大小或重复的情况下获得完整尺寸

CSS:

你试过这个吗

body {
    background-image: url("https://imgur.com/a/r9JRp");
    background-position: center top;
    background-size: 100% auto;
}
试试这个 将背景大小设置为“覆盖”

.home-3 {
    background-image: url("https://imgur.com/a/r9JRp");
    background-size: cover;
    background-attachment: fixed;
    background-repeat: no-repeat;
}

您需要添加以下CSS:

body, html {
    height: 100%;
    margin: 0;
}
.home-3{
background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
}

是的。然后它就被拉伸了。我知道有超过30Mb的图像需要下载。我仍然需要调整它们的大小。我只是想先让它工作。或者是我,但它不工作?什么都没发生,可能吗?因为我在Wordpress中使用不同的div。经过编辑和测试。差不多了!尽管如此,它还是被切断了。这是正常的吗?我通过添加一些底部填充来对其进行了一点修改:是否也可以不使用滚动?要适应屏幕?使用100vw和100vh可以删除滚动,但看起来有点拉长,如果您同意的话:
body, html {
    height: 100%;
    margin: 0;
}
.home-3{
background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
}