With that CSS, put your divs like so (floats first):
(使用该CSS,将您的div放置为这样(浮点数优先):)
<div id="container">
<div id="left"></div>
<div id="right"></div>
<div id="center"></div>
</div>
PS You could also float right, then left, then center.
(PS您也可以向右浮动,然后向左浮动,然后居中。)
The important thing is that the floats come before the "main" center section. (重要的是浮子位于“主”中心部分之前。)
PPS You often want last inside #container
this snippet: <div style="clear:both;"></div>
which will extend #container
vertically to contain both side floats instead of taking its height only from #center
and possibly allowing the sides to protrude out the bottom.
(PPS您通常希望在#container
内部最后一个代码段: <div style="clear:both;"></div>
,它将垂直扩展#container
以包含两个侧面浮标,而不是仅从#center
取其高度,并可能允许两侧伸出底部。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…