html - CSS webkit 错误 : stacked floats with width 0 and hidden overflow

标签 html css

此标记显示了我的问题: 当宽度设置为 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/

相关文章:

html - @font-face 在本地工作但在上传到托管空间时不工作

java - Html.fromHtml 在电子邮件中共享 Intent 时无法在正文中使用粗体文本

javascript - 如何使用 d3.js 创建响应式 svg

javascript - Dropzone 文件未处理

html - 无法将 san-serif 字体与 H1 标签的最边缘对齐

html - 仅将 CSS 混合模式应用于边框

html - 响应式 CSS 链接不起作用

html - 如何每隔一段时间移动我的 CSS slider ?

html - Meteor 模板强制为 HTML

html - 搜索按钮在我的代码中不起作用