次のマークアップがあると、画像の右側とテキストの下にボタンが表示されますが、が親の末尾に貼り付けられました。通常、これはthis answerごとに実行されますが、この場合フロートが存在するため、コンテンツは画像の上に表示されます。また、絶対的な位置づけは、最終的にはテキストコンテンツも重複する可能性があるので、問題になるようです。この質問の目的のために、画像の幅がであると仮定すると、が残っていると仮定してください。親の一番下で浮動兄弟の横の位置div
私はおそらく、これを再構成したり、画像を浮かべて移動したりしなければならないと思っていますが、むしろそうではありません。レイアウトを大幅に変更することなく、この作業を行うことができる、私が見落とした単純な解決策はありますか?
.wrapper {
position: relative;
overflow: auto;
}
.image {
float: left;
width: 30%;
}
.image img {
max-width: 100%;
}
.stick-to-bottom {
position: absolute;
bottom: 0;
}
button {
padding: 10px 25px;
font-size: 16px;
}
<div class="wrapper">
<div class="image">
<img src="http://www.calgaryherald.com/cms/binary/10035261.jpg" />
</div>
<div class="stick-to-top">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
</div>
<div class="stick-to-bottom">
<div>Click buttons below, but only if you are cool.</div>
<button>Button 1</button>
<button>Button 2</button>
</div>
</div>
'display:inline;'を追加する.stick-to-bottom { position:absolute; display:インライン; bottom:0; } '良いかもしれません。 –
ありがとうございます。それはトリックを行うようだ - あなたはそれを答えとして追加し、それがなぜ機能するのかを説明してもらえますか? – billynoah
ya thatまたはそれを '' – zgood