这里的问题是,你正在使用float
S,但从来没有清除它们,这意味着父元素不知道的高度延伸到。
要解决这个问题:
您可以使用微clearfix黑客从http://nicolasgallagher.com/micro-clearfix-hack/
/**
* For modern browsers
* 1. The space content is one way to avoid an Opera bug when the
* contenteditable attribute is included anywhere else in the document.
* Otherwise it causes space to appear at the top and bottom of elements
* that are clearfixed.
* 2. The use of `table` rather than `block` is only necessary if using
* `:before` to contain the top-margins of child elements.
*/
.cf:before,
.cf:after {
content: " "; /* 1 */
display: table; /* 2 */
}
.cf:after {
clear: both;
}
/**
* For IE 6/7 only
* Include this rule to trigger hasLayout and contain floats.
*/
.cf {
*zoom: 1;
}
类再放入<div id="content">
,因此它成为<div id="content" class="cf">
JSFiddle Demo
你可以在这里看到漂浮物 - 你nder部分“伟大的崩溃” - http://css-tricks.com/all-about-floats/
'container' < - 无效的标签和您共享的代码适用于我http://jsfiddle.net/eYMz3/1/ –
哇,这是很多代码在你的小提琴!来自你的问题的代码[按指定的方式工作](http://jsfiddle.net/8Z54J/)。请尝试缩小问题范围,并在问题*中包含一个[最小重复](http://sscce.org)*。 – Jeroen
你想把“照片故事”'div'放在灰色背景里吗? –