Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.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
css3在身体上堆叠2个背景图像_Css - Fatal编程技术网

css3在身体上堆叠2个背景图像

css3在身体上堆叠2个背景图像,css,Css,我想使用2个图像作为固定图像的背景图像,所以我使用了身体上的代码 background: url(images/31.jpg) 100% no-repeat, url(images/12.jpg) 100% no-repeat; background-position: fixed; 我需要它们100%适合浏览器宽度,我希望图像2垂直堆叠在图像1之后。我读过很多关于在CSS3中使用多个图像的网站。如果没有JavaScript,这是可能的吗?如果是,为什么我的图像堆叠在另一个图像之上,而图像1不

我想使用2个图像作为固定图像的背景图像,所以我使用了身体上的代码

background: url(images/31.jpg) 100% no-repeat, url(images/12.jpg) 100% no-repeat;
background-position: fixed;
我需要它们100%适合浏览器宽度,我希望图像2垂直堆叠在图像1之后。我读过很多关于在CSS3中使用多个图像的网站。如果没有JavaScript,这是可能的吗?如果是,为什么我的图像堆叠在另一个图像之上,而图像1不从左上角开始

下面的参考css尝试一下


您需要将垂直大小设置为50%左右,否则每个图像都会占据所有高度

body {
    background-image: url(http://placekitten.com/300/150), url(http://placekitten.com/200/120);
    background-size: auto 50%;
    background-repeat: no-repeat;
    background-position: top center, bottom center;
}

它只显示一张图像,而不是第二张。页面的其余部分是白色的。由于某些原因,它无法工作。当我从背景尺寸中删除汽车时,我可以看到一幅图像,但是如果我将汽车添加到背景尺寸中,我会得到一个空白页面,我已经在Chrome、Firefox和IE11中测试了小提琴。你用的是什么浏览器?此外,如果更改自动,请将其设置为100%:背景大小:100%50%;在向代码添加body时,html{height:100%;}现在可以工作了。奇怪的是,我在小提琴中包含了这个代码,但没有在答案中显示出来,因为我知道你已经将一些维度设置为body。可能你的身高为0,因此你看不到身体背景(或者身体中的其他任何东西)
body {
    background-image: url(http://placekitten.com/300/150), url(http://placekitten.com/200/120);
    background-size: auto 50%;
    background-repeat: no-repeat;
    background-position: top center, bottom center;
}