Foundation 网格 - 大型设备
详解 Foundation 5 大型设备(≥64.0625em / 1025px)的 .large-* 三档响应式组合与仅大屏分栏模式,并实测 1024px→1025px 精确断点切换。
学完这一章,你能够
- 详解 Foundation 5 大型设备(≥64.0625em / 1025px)的 .large-* 三档响应式组合与仅大屏分栏模式,并实测 1024px→1025px 精确断点切换。
三档响应式组合(小/中/大设备差异化比例)
在已为小型设备设定 `25% / 75%`(`.small-3` + `.small-9`)、为中型设备设定 `50% / 50%`(`.medium-6` + `.medium-6`)的基础上,桌面等大型设备(屏幕大于等于 `64.0625em`,16px 根字号即 `1025px` 起)可再叠加 `.large-*` 类切换为 `33.33% / 66.67%` 比例:分别为两列声明 `small-3 medium-6 large-4` 与 `small-9 medium-6 large-8`。
三档断点在各视口下的生效解析清晰分层:小型设备生效 `.small-3 / .small-9`(`25% / 75%`),中型设备生效 `.medium-6 / .medium-6`(`50% / 50%`),大型设备生效 `.large-4 / .large-8`(`33.33% / 66.67%`)。本站离线 Chromium 实测两列宽度:`375px` 下为 `[93.8, 281.3]px`、`768px` 下为 `[384, 384]px`、`1200px` 下为 `[333.3, 666.7]px`,三档均保持单行水平对齐。
仅在大型设备上水平分栏与 1025px 临界验证
若只指定 `.large-6` 而省略 `.small-*` 与 `.medium-*`,则两列在手机和平板端都会保持 `100%` 宽度纵向堆叠,直到进入大型设备视口才展开为 `50% / 50%` 左右并排。本站实测仅写 `.large-6` 的双列:`375px` 与 `768px` 下均纵向堆叠(宽 `375px` / `768px`,`stacked: true`),`1200px` 下并排为 `[500, 500]px`;进一步卡点测试 `1024px` 与 `1025px` 边界可见,`1024px` 时 `.large-6` 仍以 `1000px` 满宽堆叠且三档组合保持 `[500, 500]px`,跨至 `1025px` 瞬间 `.large-6` 切换为 `[500, 500]px` 并排、三档组合切换为 `[333.3, 666.7]px`。
大型设备网格 12 列总和提示
| 提示主题 | 核心说明 |
| 三档断点各自维持 12 列之和 | 组合 .small-*、.medium-* 与 .large-* 时,每一档断点内的列宽之和均应等于 12(如 3+9、6+6、4+8),确保所有视口下都不发生意外折行。 |
离线实测 Foundation 5 大型设备三档响应比例、仅大屏分栏与 1024/1025px 临界切换
展开查看收起
"""Offline Playwright Chromium lab for Foundation Ch 35 (grid-large)."""
import json
from playwright.sync_api import sync_playwright
FOUNDATION_GRID_CSS = """
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; }
.row { width: 100%; margin: 0 auto; max-width: 62.5rem; }
.row::before, .row::after { content: " "; display: table; }
.row::after { clear: both; }
.column, .columns { padding-left: 0.9375rem; padding-right: 0.9375rem; width: 100%; float: left; position: relative; }
.small-3 { width: 25%; }
.small-9 { width: 75%; }
@media only screen and (min-width: 40.0625em) {
.medium-6 { width: 50%; }
}
@media only screen and (min-width: 64.0625em) {
.large-4 { width: 33.33333%; }
.large-6 { width: 50%; }
.large-8 { width: 66.66667%; }
}
.demo-col { min-height: 28px; }
"""
HTML_PAGE = f"""<!DOCTYPE html>
<html lang="zh-CN">
<head><meta charset="utf-8"><style>{FOUNDATION_GRID_CSS}</style></head>
<body>
<div id="row-3tier" class="row">
<div id="t-left" class="small-3 medium-6 large-4 columns demo-col" style="background-color:yellow;"><p>左栏</p></div>
<div id="t-right" class="small-9 medium-6 large-8 columns demo-col" style="background-color:pink;"><p>右栏</p></div>
</div>
<div id="row-lrg-only" class="row">
<div id="lo-left" class="large-6 columns demo-col" style="background-color:yellow;"><p>仅大屏左</p></div>
<div id="lo-right" class="large-6 columns demo-col" style="background-color:pink;"><p>仅大屏右</p></div>
</div>
</body>
</html>
"""
def launch_browser(p):
try:
return p.chromium.launch(headless=True)
except Exception:
return p.chromium.launch(headless=True, channel="chrome")
def main():
cases = []
with sync_playwright() as p:
browser = launch_browser(p)
page = browser.new_page(viewport={"width": 375, "height": 800})
page.set_content(HTML_PAGE)
# Case 1: Three-tier responsive ratios across 375 / 768 / 1200px
actual_1 = {}
for vw in (375, 768, 1200):
page.set_viewport_size({"width": vw, "height": 800})
actual_1[str(vw)] = page.evaluate("""() => {
const a = document.getElementById('t-left').getBoundingClientRect();
const b = document.getElementById('t-right').getBoundingClientRect();
return {
widths: [Math.round(a.width * 10) / 10, Math.round(b.width * 10) / 10],
same_row: Math.abs(a.top - b.top) < 1,
};
}""")
expected_1 = {
"375": {"widths": [93.8, 281.3], "same_row": True},
"768": {"widths": [384.0, 384.0], "same_row": True},
"1200": {"widths": [333.3, 666.7], "same_row": True},
}
cases.append({
"name": "three_tier_small_medium_large_ratios",
"expected": expected_1,
"actual": actual_1,
"passed": actual_1 == expected_1,
})
# Case 2: Large-only (.large-6) stacks on small & medium, splits 50/50 on large
actual_2 = {}
for vw in (375, 768, 1200):
page.set_viewport_size({"width": vw, "height": 800})
actual_2[str(vw)] = page.evaluate("""() => {
const a = document.getElementById('lo-left').getBoundingClientRect();
const b = document.getElementById('lo-right').getBoundingClientRect();
return {
widths: [Math.round(a.width * 10) / 10, Math.round(b.width * 10) / 10],
same_row: Math.abs(a.top - b.top) < 1,
stacked: b.top >= a.bottom - 1,
};
}""")
expected_2 = {
"375": {"widths": [375.0, 375.0], "same_row": False, "stacked": True},
"768": {"widths": [768.0, 768.0], "same_row": False, "stacked": True},
"1200": {"widths": [500.0, 500.0], "same_row": True, "stacked": False},
}
cases.append({
"name": "large_only_stacks_on_small_and_medium",
"expected": expected_2,
"actual": actual_2,
"passed": actual_2 == expected_2,
})
# Case 3: Exact 64.0625em (1025px) threshold check (1024px vs 1025px)
actual_3 = {}
for vw in (1024, 1025):
page.set_viewport_size({"width": vw, "height": 800})
actual_3[str(vw)] = page.evaluate("""() => {
const t1 = document.getElementById('t-left').getBoundingClientRect();
const t2 = document.getElementById('t-right').getBoundingClientRect();
const l1 = document.getElementById('lo-left').getBoundingClientRect();
const l2 = document.getElementById('lo-right').getBoundingClientRect();
return {
three_tier_w: [Math.round(t1.width * 10) / 10, Math.round(t2.width * 10) / 10],
large_only_w: [Math.round(l1.width * 10) / 10, Math.round(l2.width * 10) / 10],
large_only_same_row: Math.abs(l1.top - l2.top) < 1,
};
}""")
expected_3 = {
"1024": {
"three_tier_w": [500.0, 500.0],
"large_only_w": [1000.0, 1000.0],
"large_only_same_row": False,
},
"1025": {
"three_tier_w": [333.3, 666.7],
"large_only_w": [500.0, 500.0],
"large_only_same_row": True,
},
}
cases.append({
"name": "large_breakpoint_exact_threshold_1024_vs_1025",
"expected": expected_3,
"actual": actual_3,
"passed": actual_3 == expected_3,
})
browser.close()
print(json.dumps({"cases": cases}, ensure_ascii=False))
if __name__ == "__main__":
main()
查看独立实例 ↗ 在独立页面查看源码、运行环境与工程包
本地运行
解压后按 README 说明在对应本地环境运行脚本。
本章附件与实例包
常见错误与边界检查
- 实际端口、文档资源与应用配置都应和测试条件一致。
技术规范与官方资料
练习与参考解答
查看参考解答
会上下堆叠(每列宽 1000px,受 .row 最大宽度约束)。因为 Foundation 5 大型设备断点为 min-width: 64.0625em,按 16px 根字号换算为 1025px,1024px 仍处于 medium 区间上限,.large-6 尚未生效。