2012-10-31 14 views
1

我需要將2個div放在一起,以便它們水平對齊。如果右邊的div高一些,它不應該在底下,而應該包在底下。水平對齊不同高度的2個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> 

回答

2
#left, #right {float:left; border:1px solid black; margin:10px; width:45%;}