1

我需要将 2 个 div 浮动在一起,以便它们水平对齐。如果右侧的 div 较高,则它不应位于其下方,而应包裹在其下方。

<html>

<style>
#left, #right {float:left; border:1px solid black; margin:10px;}
</style>

<div id="container">

<div id="left">
this is an image, the hight and width can vary
</div>
<div id="right">
this div should never wrap underneath the image.  if it is higher than left image it needs to wrap under itself so the space directly beneath the image is respected
</div>

</div>
<div style='clear:both;'></div>

<hr>

<div id="left">
this is an image, the hight and width can vary
</div>
<div id="right">
this div should never wrap underneath the image.  if it is higher than left image it needs to wrap under itself so the space directly beneath the image is respected
</div>

</div>
<div style='clear:both;'></div>
</html> 
4

1 回答 1

2
#left, #right {float:left; border:1px solid black; margin:10px; width:45%;}
于 2012-10-31T17:50:03.903 回答