絶対位置の要素を相対位置の要素の下に配置しようとしています。ブルーボックスは、サイト開発内の制約のために比較的配置する必要があります。
ふきだしが青いボックスで、ふきだしの尾が:after疑似要素であると想像してください。これらの2つの要素の背景を保持するために、これらの両方の背後にある緑色のボックスが必要です。
div.layer01 {
background-color: blue;
position: relative;
z-index: 10;
}
div.layer01:after { /* This is the tail of the bubble */
display: block;
background-color: red;
content: '\00a0';
width: 30px;
height: 30px;
position: absolute;
right: 20px;
top: 50px;
border: 3px #fff solid;
}
/* This should be behind the tail and the blue box (bubble) */
div.layer01 div.layer02 {
background-color: green;
width: 320px;
height: 125px;
display: block;
position: absolute;
z-index: 5;
}
<div class="layer01"> <!-- speech bubble -->
<div class="layer02">Why isn't this below the blue?</div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus non dolor quis leo malesuada pharetra at in massa. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>
</div>
修理:
比較的配置された要素から配置したい要素を取得し、コンテンツを新しいdivにラップしました。マークアップを追加しますが、これが唯一の方法のようです。