【发布时间】:2022-01-10 12:04:54
【问题描述】:
我有一个 div,其中包含必须相互叠加的图像。 (在示例中仅使用一张图像,但通常是不同的图像。
我正在使用 position:absolute 将它们放在一起
<div class=container>
<img src=https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png class=childImage>
<img src=https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png class=childImage>
<img src=https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png class=childImage>
<img src=https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png class=childImage>
<img src=https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png class=childImage>
</div>
<div id=underneath>
should be underneath
</div>
css:
.container{
position:relative;
}
.childImage{
position:absolute;
}
我需要将 id=underneath div 放在容器下方。但目前它显示在它之上。有没有强迫它在下面?我可以使用 margin-top 强制它向下,但这不是最佳选择,因为图像会根据浏览器视口大小调整大小(使用引导 img-fluid,我相信它会自动设置高度和宽度。所以我没有一个size 适合所有 margin-top,因为它会因视口而异。
【问题讨论】:
标签: html css image css-position layer