ie6下padding bug

今晚发现ie6下原来还有一个bug,看代码:

<!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=UTF-8" />
<title></title>
<style type="text/css">
    *{ margin:0; padding:0;}
    #layout{ padding-top:10px;}
    #layout .test1,#layout .test2{ height:20px; border:1px solid #ccc;}
    #layout .test1{ float:left;}
    #layout .test2{ clear:both;}
</style>
</head>
<body>
    <div id="layout">
        <div class="test1">test1</div>
        <div class="test2">test2</div>
    </div>
</body>
</html>
这样,在IE6下,浮动层后的层也有padding-top,谷歌了下,说是什么3像素引起的,我原来自己的解决方案是在test2这个div里加个margin-top:-10px;这样解决,但发现可以通过给#layout这div一个zoom:1激活haslayout,从而解决问题。标记以记之。

posted @ 2011-05-01 22:39  肥杜  阅读(3023)  评论(0编辑  收藏  举报