首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > CSS >

div中float属于的奇怪现象~(有代码),该如何处理

2012-09-28 
div中float属于的奇怪现象~~(有代码)如果需要在一个div中动态添加内容,则这个div动态改变高度大小,但是如

div中float属于的奇怪现象~~(有代码)
如果需要在一个div中动态添加内容,则这个div动态改变高度大小,但是如果动态添加的内容通过 float 属性设置后,该div块的background-color 属性便会失效,请问该如何解决这个问题呢?谢谢~~

前提条件:1、该 div 必须不能指定高度 2、div块必须要设置背景色

HTML code
<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>


[解决办法]
啥意思? 有代码测试不?
[解决办法]
加入 "min-Height:20px " 属性即可。
div使用了 float属性,高度变为当前内容的高度,代码中没有内容所以高度为0,当然就看不见背景了

热点排行