我似乎无法找到正确完成此任务的方法。我有两个容器。在一个容器中,我想使用将水平占据整个上半部分的背景图像,然后我想使用第二个容器并将其涂成红色。这将水平占据下半部分。
我试过这个:
HTML:
<div class="container1">
Some text and other divs go here. This is where the background will be an image.
</div>
<div class="container2">
Some text will also here along with divs. This is where I want to use the red background.
</div>
CSS:
.container1 {
background-image: url('img.png');
width:100%;
}
.container2 {
width: 100%;
color: #990000;
}
问题是对于图像容器,我在顶部、底部、左侧和右侧留下了空白。
我该如何解决这个问题?