尝试使用 CSS 来定位一个 div,这样:
a)它出现在其包含之外div
(我可以这样做),并且,
b) 的底部边缘div
与其包含的顶部边缘相邻div
(我正在努力解决)。
从视觉上看,最终结果应该是 div 似乎位于其 contains 之上,div
如下图所示:
注意:图中“A”的高度div
根据其内容而有所不同,因此将其“top”属性设置为“-150px”或其他一些负常数将不起作用。我也试图避免使用 JS,但如果我不能单独使用 CSS 来实现这一点,我会使用它。
示例代码:
<body>
<div id="div-B" style="
position: absolute;
top: 200px;
left: 200px;
height: 200px;
width: 200px;
background: red;
">
<div id="div-A" style="
width: 150px;
background: green;
">
This is a bunch of text. This is a bunch of text. This is a bunch of text. This is a bunch of text. This is a bunch of text. This is a bunch of text.
</div>
</div>
</body>
谢谢!