我有两个左右浮动的 div。它们位于 overflow hidden 的父 div 内。问题是,向右浮动的一个比另一个长,而另一个 div 不会延伸到父 div 的底部,因此左侧有一大片灰色。
这是我的代码:
<div class="content">
<div class="left">
Blue Bottle pork belly messenger bag squid narwhal. Yr craft beer iPhone pug, flexitarian PBR&B retro chia wayfarers. Vice seitan DIY, mlkshk single-origin coffee mustache 8-bit butcher farm-to-table dreamcatcher distillery photo booth brunch aesthetic banjo.
</div>
<div class="right">
Wolf forage flannel seitan, vinyl small batch authentic Etsy plaid swag. Ennui ugh fashion axe Helvetica normcore meggings, American Apparel leggings kale chips paleo scenester. Etsy try-hard photo booth, tousled bicycle rights swag Schlitz gentrify chia tattooed pork belly tofu. Raw denim pork belly squid, bespoke sartorial direct trade umami blog Etsy paleo 90's beard roof party letterpress bicycle rights. Butcher street art pour-over, Brooklyn Shoreditch semiotics yr fingerstache fixie Echo Park. Readymade irony gastropub ethical Pitchfork. Skateboard keytar vinyl, deep v lomo tofu gentrify gastropub try-hard Echo Park Cosby sweater Tumblr tote bag.
</div>
<div class="clear"></div>
</div>
这是一个 fiddle
最佳答案
您可以将 min-height
添加到您的 .right
和 .left
div:
.left, .right{
min-height:100px; // or one can select 100% as per requirement
}
关于html - 将 float 的 div 高度扩展到父 div 的底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25277354/