tags:

views:

39

answers:

2

Hello,

This markup shows my problem: Webkit browsers seem to create an erroneous width on floated parent elements with floated/overflow:hidden elements inside, when their width is set to 0. Is there a known workaround?

<!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>
A: 

Do you have a doctype enabled? Page is in quirks mode as of now.

meder
Yes, I do. I updated the code. Doctype does not have any effect, unfortunately.
Jan Limpens
A: 

One can get consistent behaviour (at least between webkit and gecko) by giving the outer element some width. Bit of a drag, but doable.

Jan Limpens