代码是不是这样的啊?
<ul>
<li style="float:left">test float</li>
</ul>
<div>after div</div>
如果是的话, 出来的效果是li跟div在一排了
因为没有clear, 这样就会好:
<ul>
<li style="float:left">test float</li>
</ul>
<div style="clear:both"></div>
<div>after div</div>
建议的做法是这样, 代码会好看一些, 而且兼容各种浏览器哦
<style>.clearfix:before, .clearfix:after { content:""; display:table; }.clearfix:after { clear: both; }.clearfix { zoom: 1; }</style><ul class="clearfix"><li style="float:left">test float</li></ul><div>after div</div>如果你问的为什么要clear的话, 请看这里:
http://w3school.com.cn/css/css_positioning_floating.asp