此标记显示了我的问题: 当宽度设置为 0 时,Webkit 浏览器似乎会在带有 float /溢出:隐藏元素的 float 父元素上创建错误的宽度。是否有已知的解决方法?
<!DOCTYPE html>
<html>
<head>
<title>float & width</title>
<style type="text/css">
div {
float: left;
height: 50px;
}
div.section {
background-color: green;
}
div.section div.content {
background-color: red;
overflow: hidden;
}
p {
clear: both;
}
</style>
</head>
<body>
<p>width: 0 => Bug</p>
<div class="section">
<div class="content" style="width: 0;">some content that should not affect the parent div's width.</div>
</div>
<p>width: 1px => good</p>
<div class="section">
<div class="content" style="width: 1px;">some content that should not affect the parent div's width.</div>
</div>
</body>
</html>
最佳答案
您是否启用了文档类型?页面目前处于怪癖模式。
关于html - CSS webkit 错误 : stacked floats with width 0 and hidden overflow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3920210/