我需要将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>
答案 0 :(得分:2)
#left, #right {float:left; border:1px solid black; margin:10px; width:45%;}