印刷媒體(雜誌、報紙)擁有極靈活的多欄、不規則區域排版能力。Web 受限於文檔流線性特性,難以實現類似效果。CSS3 Regions 模塊應運而生:內容流動指定區域,而非綁定特定容器。
flow-into: <ident>flow-from: <ident>實驗階段,僅 Chrome (需啟用 chrome://flags → "啟用實驗性 WebKit 特性") 和 IE 支援帶前綴屬性。
<header class="cf">...</header>
<article class="cf"><p>主要內容...</p></article>
<aside><p><img src="stat.jpg"></p><p>側邊內容...</p></aside>
<div class="regions cf">
<div id="region-1" class="region cf"></div>
<div id="region-2" class="region"></div>
<div id="region-3" class="region"></div>
<div id="region-4" class="region cf"></div>
</div>
/* 區域尺寸 - 高度必須指定,決定斷點 */
#region-1, #region-4 { width: 100%; height: 250px; }
#region-4 { height: 400px; }
#region-2, #region-3 { width: 50%; height: 700px; margin-bottom: 25px; }
/* 內容流向映射 */
article { -webkit-flow-into: article; flow-into: article; }
aside { -webkit-flow-into: aside; flow-into: aside; }
#region-1, #region-2, #region-4 {
-webkit-flow-from: article; flow-from: article;
}
#region-3 {
-webkit-flow-from: aside; flow-from: aside;
}
關鍵點:flow-into/flow-from 後的標識符自定義 (如 article, aside),區域在 DOM 中位置不影響流向。
Regions 尚未標準化,生產環境建議考慮: