1

Something strange is happening with a margin setting in Firefox, I have a div with an id "wrap" with a top margin of 20px, when a user is logged in a div appears above the wrap div with an id of user_nav I don't want any margin above this div, but Firefox is for some unknown reaslon propagating the top margin I have on the wrap div to the user_nav div above it, it isn't happening in any other browsers.

If I remove the top margin from the wrap div it is removed from both.

I can get rid of it by giving the user_nav div a negative top margin, but that messes up all the other browsers.

div#user_nav {
width: 980px;
margin: 0 auto;
}


div#wrap {
width: 980px;
margin: 20px auto 30px auto;
}

Any ideas about what is happening?

Thanks

Rob Fenwick

4

1 回答 1

1

这确实是一种古怪的行为——它似乎是这个与清除块元素(或其众多重复项之一)相关的旧错误的影响之一:

https://bugzilla.mozilla.org/show_bug.cgi?id=451791

解决它的一种方法是摆脱<div class="clear">并使用溢出的清除方法(尽管这并不总是可能的,例如 - 显然 - 如果您在已清除元素内有内容将延伸到它之外):

http://www.quirksmode.org/css/clearing.html

即,<div class="clear">从内部删除user_nav_frame并在 CSS 中对其应用overflow: hidden(和width: 100%)以清除浮动:

div#user_nav_frame {
    background-color: #0A4D84;
    overflow: hidden;
    width: 100%;
}

JSFiddle:http: //jsfiddle.net/69aD9/2/

如果这在您的情况下不起作用,也有反黑客攻击。请参阅上面的错误报告。

于 2013-04-28T21:28:43.107 回答