我需要将这两个div叠加在一起,但我很难找到一种方法使它成为可能.我需要将文本保持在相同的位置,但需要能够将div放在一个上面,而不需要为它们设置绝对位置. 这是我的…… <body><d
... . . 我需要将这两个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>.
解决方法
. 您应该将两个div的内容放在具有“position:relative”的外部div中,并将绝对定位放在内部div上,并为每个div添加一个z-index.然后将较大的z-index放在较小的z-index上.
<body> <div style="position:relative;"> <div style="position:absolute;z-index:0;"> <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 style="position:absolute;z-index:1;"> <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>. . .. ...