0
我有一个左浮动div与2行左浮动子块。每行都用一个简单的清除块清除。如何防止浮动子项的浮动父项在IE6中扩展为100%宽度?
问题是,IE6将父块的宽度扩展为可用空间的100%,而在其他浏览器中,父宽度设置为完全包裹子级。
当所有子块都浮动时,宽度在IE6中是正确的。但是我需要将儿童区块排成行,所以我在每行之后放置了一个额外的清晰区块。之后,父母的宽度扩大到100%。
有没有一种解决方法,在IE6中具有正常的父级块宽度? (表是不欢迎)
Have a look at the image illustrating the problem
<!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" lang="en" xml:lang="en">
<head>
<style type='text/css'>
#parent {
float: left;
background-color: black;
}
.block {
width: 30px;
height: 30px;
background-color: yellow;
margin: 10px;
float: left;
}
.clear {
height: 1px;
clear: both;
font-size: 1px;
line-height: 0px;
}
</style>
</head>
<body>
<div id="parent">
<div class="block">1</div>
<div class="block">2</div>
<div class="block">3</div>
<div class="block">4</div>
<div class="clear"></div>
<div class="block">5</div>
<div class="block">6</div>
<div class="block">7</div>
<div class="block">8</div>
<div class="clear"></div>
</div>
</body>