如何使用css设置响应性背景图像(在窗口中自动调整大小)?

如何使用css设置响应性背景图像(在窗口中自动调整大小)?,css,Css,我希望我的背景图像像壁纸一样。但是我需要一些帮助来使用css。 这是我的css: #wallpaper{ position: absolute; background-size: cover; background-image: url(C:\Users\Pedro\Desktop\ASK2DOC landing_page\wallpaper.jpg); background-repeat: no-repeat; top: auto; left: auto; right: auto; heigh

我希望我的背景图像像壁纸一样。但是我需要一些帮助来使用css。 这是我的css:

#wallpaper{
position: absolute;
background-size: cover;
background-image: url(C:\Users\Pedro\Desktop\ASK2DOC landing_page\wallpaper.jpg);
background-repeat: no-repeat;
top: auto;
left: auto;
right: auto;
height: auto;
}
请尝试以下操作:

#wallpaper {
    background: url(/*image_path*/) no-repeat center center fixed; 
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}

如果不起作用,请单击。

如果要覆盖整个屏幕,只需执行以下操作:

body {
    background-size: cover;
    background-image: url(/wallpaper.jpg);
    background-repeat: no-repeat;
}

图像应位于此网站的默认目录中。

AFAIK您不能仅使用CSStry将CSS中的
高度设置为
100vh
宽度设置为
100vw
。还有,为什么CSS中有左值和右值?还有@apparatix你错了,你肯定错了can@Markasoftware你可能是对的,我的CSS知识很差:)你说的“像墙纸”是什么意思?这很有效,但OP似乎想让元素填满尖叫,我可能会选择将
高度
宽度
设置为
100%
100vh
100vw
以填充屏幕