100% div 导致孩子的下边距被切断

  • 本文关键字:div 孩子 100% css margin
  • 更新时间 :
  • 英文 :


我有一个 100% 高度的 #wrapperdiv。在其中,我有几个内容div,每个都显示为内联块并具有底部边距。问题是这个底部边距以某种方式被折叠了。

这个问题可以用非常简单的代码看到:

<div id="wrapper">
    <div id="content">
        <!-- lots of content here that will fill the browser window -->
    </div>
</div>

我创建了一个示例,可以在这里看到:http://jsfiddle.net/Y6tJw/

我有一种感觉,这是一个webkit问题,因为Firefox和IE都以适当的边距呈现页面。有什么帮助吗?

不要问我为什么有效,但这 http://jsfiddle.net/Y6tJw/2/

风格

#wrapper { height: 100%; background: blue; }
#innerwrap { padding-bottom:300px; background: blue;}

.HTML

<div id="wrapper">
<div id="innerwrap">
<div id="content">
    <!-- lots of content here that will fill the browser window -->
</div>
</div>
</div>
发生这种情况

是因为您在min-height时给了您的身体 100% 的高度。尝试给height:auto;这会起作用

最新更新