我这几天遇到一个问题,就是在IE7和FF下完全正常的代码,在IE6下就会有问题, 自己研究了很长时间没有弄明白,在别人的帮助下,才找到了原因. 原来是因为书写代码时的一个回车符.
比如有这样一段代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<div style="background-color:#9900FF; margin:0; padding:0"><img style="margin:0; padding:0; background-color:#999999" src="http://hi.csdn.net/Styles/V1.3.0/images/logo.gif" alt="CSDN" />
</div>
</body>
</html>
这代码在IE7和FF下完全正常, 可是在IE6下就有问题, 下面会多出一小段空白.
当我把代码改成这样,就没有问题了:
<div style="background-color:#9900FF; margin:0; padding:0"><img style="margin:0; padding:0; background-color:#999999" src="http://hi.csdn.net/Styles/V1.3.0/images/logo.gif" alt="CSDN" /></div>
就是把DIV的后边那个封闭标签放在和IMG同一行上,就可以了. 这或许是IE6的BUG吧,很是奇怪.