分组 · 对齐 · 间距 · 自适应 — 用留白而非线条来组织,移动端照样成立。
按优先级取工具:① 负空间(默认)② 背景形状(卡片)③ 分隔线(仅密集数据)。需要分隔线时保持低对比发丝线,别配已经完成任务的大间距。
.form{ display:flex; flex-direction:column; gap:24px; }
.field-group{ display:flex; flex-direction:column; gap:8px; }
/* 坏:均匀间距又加底线去补偿 */
.form > *{ margin-bottom:12px; border-bottom:1px solid var(--separator); }
text-align:end,文字 text-align:start。.section{ padding-inline:24px; }
.section .child{ margin-inline-start:16px; } /* 一个引导边 + 一个缩进步 */
/* 坏:一列里三个不相关的引导边 */
任何会镜像的东西用逻辑属性,RTL 下自动反向;translateX、background-position、手写 left/right 不会镜像。
| 物理 | 逻辑 |
|---|---|
| margin-left | margin-inline-start |
| padding-right | padding-inline-end |
| left:0 | inset-inline-start:0 |
| text-align:left | text-align:start |
| border-right | border-inline-end |
| border-top-left-radius | border-start-start-radius |
别把用户来的核心数字埋在次要细节下面。把次要细节收进折叠区、标签或详情视图。
| 之间 | 起点 |
|---|---|
| 相邻有边框/填充的控件(按钮、输入框) | 12px |
| 无边框控件的可见字形(文字/图标按钮) | 24px |
| 无关控件组 | 24px 或更多 |
.article{ display:grid; grid-template-columns:1fr min(65ch, calc(100% - 48px)) 1fr; }
.article > *{ grid-column:2; }
.article > .full-bleed{ grid-column:1 / -1; }
.card-list{ container-type:inline-size; }
@container (width < 400px){ .card{ grid-template-columns:1fr; } } /* 组件随容器自适应 */
/* 坏:视口媒体查询会在窄侧栏里把卡片打断 */
grid-template-columns:minmax(0,1fr) 和 flex 子项 min-width:0。100dvh(非 100vh)避开移动端工具栏;模态给 max-height:100dvh+滚动体+滚动区外的操作行。安全区用物理值:浮动按钮要把每个物理边各自配 inset,并在 RTL 下覆盖。html{scroll-padding-block-start:var(--header-height)} 让吸顶头部不遮挡锚点/聚焦目标。