任意の例として、div
間に画像がある 2 つの がある場合、
<div class="section1">
<h2>Stuff in section one</h2>
</div>
<img src="../img/logo.png" class='myimg'>
<div class="section1">
<h2>Stuff in section two</h2>
</div>
<div class="section2">
<div class="container">
<h2 style="color:white">Stuff in section one</h2>
</div>
</div>
そして、その画像をブロックとして表示し、20 ピクセル上に調整したいとします。
.myimg{
position: relative;
display: block;
margin-top: 0px;
margin-bottom: 0px;
bottom: 20px;
margin-right: auto;
margin-left: auto;
}
正常に動作しますが、section2
div は画像があるべき場所 (実際の場所より 20 ピクセル下) から開始されます。
次の要素 (section2
この場合) に、前に来た相対的に配置された要素を「認識」させて、その要素が実際に終了する場所から開始する方法はありますか?