div中float属于的奇怪现象~~(有代码)
如果需要在一个div中动态添加内容,则这个div动态改变高度大小,但是如果动态添加的内容通过 float 属性设置后,该div块的background-color 属性便会失效,请问该如何解决这个问题呢?谢谢~~
前提条件:1、该 div 必须不能指定高度 2、div块必须要设置背景色
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><style type="text/css">#content{ margin:50px 20px 50px; 200px; background-color:#999; display:block; padding: 10px; position: relative;}#d01, #d02{ float:left; width:200px; height:200px; background-color:#06F;}#d02{ background-color:#FF0;}</style></head><body><div id="content"><div id="d01"></div><div id="d02"></div><div></body></html>