フレックスボックスを使用すると、<p>
を親の「終わり」にどのように揃えることができますか?フレックスアイテムをコンテナの終わりに合わせる
ドキュメントによると、align-content: flex-end
を親要素に追加するだけで十分です。ただし、これは以下の例では機能しません。
例:ここでは
はp
要素を含む単純なdiv要素です。
div {
display: flex;
flex-direction: column;
align-content: flex-end; /* This should do the alignment, but doesn't. */
background: yellow;
padding: 50px;
height: 300px;
width: 400px;
}
<div>
<p>Align me to the end.</p>
</div>
ハックソリューションは、flex: 1
で子供に::before
を追加することですが、よりよい解決策がある場合、私は興味があります。