关于CSS浮动的问题:左

时间:2010-09-19 15:29:11

标签: css

   <div style="width: 800px;border:1px solid black">
          <div style="width:100px;height:100px;float:left;border:1px solid black"></div>
          <div style="float:left">ssdfsdfsdfsdgfag25w6a4g8w5614w5sge16dgf45d4sdffffffffffffffffffffffffffffffffffffffffffffffffffffff5s4f64s6f456a46f456a456456456f456we4f54we5gf45456v4sd5646sadf54s56f465as4f564as56f</div>
          <div style="clear:both"></div>
    </div>

它最终是这样的: alt text 如何解决它

2 个答案:

答案 0 :(得分:2)

在第二个子div上放一个宽度。你还需要在该字符串中放置一个空格,因为它不能将它包裹在行中。

 <div style="width: 800px;border:1px solid black">
          <div style="width:100px;height:100px;float:left;border:1px solid black"></div>
          <div style="float:left; width: 100px">ssdfsdfsdfsdgfag25w6a4g8w5614w5sge16dgf45d4sdffffffffffffffffffffffffffffffffffffffffffffffffffffff5s4f64s6f456a46f456a456456456f456we4f54we5gf45456v4sd5646sadf54s56f465as4f564as56f</div>
          <div style="clear:both"></div>
    </div>

答案 1 :(得分:0)

将主要div的高度设置为100