這裏的問題是,你正在使用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'放在灰色背景裏嗎? –