两个div之间的匿名空白 [英] Anonymous white space between two divs
问题描述
以下是小提琴,
我有两个 divs
一个用于标题,另一个用于主体。在用于标题的 div
中,我有另外一个 div
,而div是浮动左
。由于浮动
,这两个 divs
之间出现空白区域(在main和div的div之间身体)。
[注意:请参阅 #DivLogo
在小提琴的css部分]
我的问题是,为什么这种问题因浮动而上升。
这是使您的#DivHeader为 inline-block
。将其更改为 display:block
并将 overflow:hidden;
设置为包含浮点数。请参阅 http://jsfiddle.net/jhcUb/
Here is the Fiddle,
I have two divs
one is for header and the other is for the main body. Inside the div
which is for header, i'm having another div
and that div was floated left
. Due to that floating
, a white space has occurred between those two divs
(between the div for header and div for main body).
[Note: Please refer #DivLogo
in the css section of the fiddle]
My question is, why this kind of problem is raising due to floating.?
It's an artifact of having your #DivHeader be inline-block
. Change it to display: block
and set overflow: hidden;
to contain the floats. See http://jsfiddle.net/jhcUb/
这篇关于两个div之间的匿名空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!