侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

css – 我需要将这两个div叠加在一起,同时保持内容位置

2023-04-06 星期四 / 0 评论 / 0 点赞 / 38 阅读 / 1879 字

我需要将这两个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>
. . .. ...

广告 广告

评论区