Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
357 views
in Technique[技术] by (71.8m points)

html - Firefox body margin bug?

I have this simple example:

<header>
    <ul>
        <li>Item</li>
        <li>Item</li>
        <li>Item</li>
        <li>Item</li>
        <li class="clear"></li>
    </ul>
</header>
<section>section</section>

And this piece of css:

BODY, HTML{
    margin: 0;
}
header{
    margin-bottom: 100px; /* section goes down */
}
UL{
    list-style-type: none;
}
UL LI{
    float: left;
    background: green;
}
.clear{
    clear: both;
    float: none;
}
section{
    background: red;
}

So I expecting to "header" goes straight to top-left corner, then 100px margin, then "section". In all major browsers that works as expected, but in Firefox (version 16) "header" get extra margin-top for some reason.

Is this a bug?

Here an jsfiddle example: http://jsfiddle.net/AvZek/2/

BTW If I used clearfix instead of "clear" class than it's working just fine.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This is, without a doubt, a bug. The margin is definitely not supposed to be there.

  • According to Firebug, the only non-zero margin that is computed that I can see is the same margin-bottom: 100px on your header element as in your CSS. Everything else is zero.

  • Even Firebug's DOM inspector has trouble identifying it; it never highlights that region, with the obvious exception of when you're inspecting html itself (which it highlights as part of its content area).

I found tons of bug reports which were closed as duplicates of this one, with numerous more test cases. Plus, it looks like it has been around since at least Firefox 2.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...