我需要将这两个 div 堆叠在一起,但我无法找到实现它的方法。我需要将所有文本保持在相同的位置,但需要能够让 div 位于一个和另一个之上,而不需要为它们设置绝对位置。
这是我所拥有的…
<body>
<div style="position:relative;">
<div style="position:absolute">
<p style="width: 762px; left:193px;" class="large-bold-font">hello hello helloT</p>
<p id="Customer.Description" style="left: 397px; top: 45px;" class="small-font"></p>
</div>
</div>
<div style="position:relative;">
<div style="position:absolute">
<p style="width: 762px; left:193px;" class="large-bold-font">hello hello helloT</p>
<p id="Customer.Description" style="left: 397px; top: 45px;" class="small-font"></p>
</div>
</div>
</body>
原文由 user3233834 发布,翻译遵循 CC BY-SA 4.0 许可协议
您应该将两个 div 的内容放在具有“position:relative”的外部 div 中,并将绝对定位放在内部 div 上,并为每个 div 添加一个 z-index。然后将较大的 z-index 放在较小的 z-index 之上。