如何在背景体中添加多个图像

时间:2016-11-25 14:13:47

标签: html css

所以我想创建一个网站,我可以让背景有一个标题为600px图片的标题图片,即“site background”,其余部分是平铺图像,如以及我希望标题背景适应移动,例如background-position: center; CSS属性。

我查看W3,但他们的文档令人困惑。 here

这是我试过的一些代码:

background: url(bg.png) top, url(tile.png) repeat;

但我不确定如何将background-position & height添加到其中。

1 个答案:

答案 0 :(得分:1)

简短的例子:



.web {
    width: 800px;
    height: 1000px;
    background-image: url(https://dummyimage.com/800x600/000/fff), url(https://dummyimage.com/800x300/555/fff);
    background-size: 300px 200px, 300px 100px;
    background-repeat: no-repeat, no-repeat;
    background-position: center 0px, center 200px;
}

<div class="web"></div>
&#13;
&#13;
&#13;