我的主容器有相对位置,我希望将2张图像叠加在一起。
当我向其中一个div添加绝对位置时,它就会消失。
我尝试使用左上角的定位等。我附上了图像的假设。
这是我的代码
<div style="position: relative;">
<div style="background: url('http://i.imgsafe.org/8797eaa.png') no-repeat; background-size: 100% auto; height: 709px;margin-top: 70px"></div>
<div style="background: url('http://i.imgsafe.org/8ab6260.png') no-repeat; background-size: 100% auto; height: 170px;position: absolute; top:0; left: 0"></div>
</div>
有什么建议吗?
答案 0 :(得分:1)
答案 1 :(得分:1)
你忘记了,所以指定绝对div的宽度。在css中添加width: 100%
。