我想使用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不是从左上角开始?
答案 0 :(得分:0)
以下参考css试试吧
#idName {
background-image: url(image1.png),url(image2.png);
background-position: center bottom, left top;
background-repeat: no-repeat;
}
答案 1 :(得分:0)
您需要将垂直尺寸设置为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;
}