Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
divA内のdivB内にdivCがあります。
Div Aの幅は700pxに設定され、divCの幅は100pxに設定されています。DivBには幅が設定されていません。
私の問題は、div Bが幅を100%に拡張することです(div Aの幅に合わせるため)。div B、つまり彼の幅を子divに準拠させる方法はありますか?div Cと、divCの近くに配置した他のdivをラップするようにします。
次のコードを使用して結果を得ることができます。
#b { margin:0px auto; overflow:hidden; display:table; }
これにより、目的の結果が得られるはずです。
B div を浮動要素にして、幅を子に合わせて調整します。
<div id="B" style="float:left;">