DIV被图片撑开的解决办法

时间:2015/12/2 15:28:00来源:互联网 作者:flyso 点击: 791 次

图片总是把DIV撑高4像素,不知为什么??下面的方法能解决,不过总觉得不是很完美,总要定义DIV的高度

<style>
*{margin:0; padding:0}
#test1{ background:#ff0000; height:110px; overflow:hidden}
#test1 li{ list-style:none; }
#test2{ background:#ffff00; }
</style>
</head>
 
<body>
<div id="test1"><ul><li><img src="http://www.google.cn/intl/zh-CN/images/logo_cn.gif" ></li>
</ul></div><div style="clear:both;"></div>
<div id="test2"><ul><li><img src="http://www.google.cn/intl/zh-CN/images/logo_cn.gif" ></li>
</ul></div><div style="clear:both;"></div>
<div><script>
document.write("图层一的高度是"+document.getElementById("test1").offsetHeight);
document.write("--------图层一的高度是"+document.getElementById("test2").offsetHeight);
</script></div>


Copyright © 2005 - 2016 flyso.cn. 飞搜 版权所有 鄂ICP备11002783号-3