圆角看起来只是几个像素的差别,但它决定了嵌套界面是否规整。

很多界面单独看没有问题,叠在一起却显得松:卡片、输入框、按钮和标签各有各的圆角,圆心没有对齐,视觉上就会像几块互不相干的积木。

问题不在大小,在圆心

当一个元素放在另一个圆角容器里,如果内外圆角没有落在同一个圆心,即使数值接近,也会出现不均匀的边距。

判断方法很简单:把两个圆角的圆心对齐,观察四条边的间距是否一致。只要圆心和间距一致,嵌套关系就会自然稳定。

递进式圆角:r = R - p

如果外层容器的圆角是 R,内层元素与容器之间的内缩距离是 p,那么内层圆角应为:

1
r = R - p

例如:

  • 外层对话框圆角 32px,内边距 16px,内部面板和按钮使用 16px;
  • 16px 面板里的 chip 与面板边缘相距 8px,chip 使用 8px。

从外到内按层级计算:

1
对话框 / 卡片 → 面板、输入框、按钮 → chip、标签

同一层级的盒子共用同一个圆角值。除胶囊和圆形外,圆角不要低于 4px;padding、gap 和 radius 尽量统一在 4px 网格上。

这个公式成立的前提是内外元素同心、内缩距离一致。遇到不对称内边距时,需要分别计算四角,不能用一个数值硬套。

如果项目已经定义 radius token,优先修改 token,而不是在每个组件里散落硬编码。

连续曲率:让圆角消失得更自然

普通 border-radius 画出的是一段圆弧。圆弧与直边相接时,曲率变化比较直接,容易在视觉上留下转折。

连续曲率圆角(超椭圆)会拉长过渡区域,让边界从直边进入圆角时更顺,接近 iOS 等系统界面的观感。

1
2
3
4
5
6
7
8
9
10
11
12
13
.card {
border-radius: 32px;
}

@supports (corner-shape: superellipse(1.25)) {
.product-shell :where(*) {
corner-shape: superellipse(1.25);
}

.product-shell :where(.avatar, .pill, .circle) {
corner-shape: round;
}
}

border-radius 继续保留,作为所有浏览器的基础形状;corner-shape 只做渐进增强。Chrome 和 Edge 139+ 会渲染超椭圆,Safari 和 Firefox 会跳过这段规则,回退到普通圆角。

实际项目里建议把选择器限制在目标页面或组件容器内,而不是无差别应用到全站。胶囊、头像和圆形元素仍应保持 corner-shape: round,避免连续曲率破坏它们原本的几何语义。

检查清单

  • 从最外层开始,逐层计算 r = R - p;
  • 同层元素是否共用同一个圆角;
  • 内外圆角是否共用圆心;
  • padding、gap、radius 是否落在同一套尺度上;
  • 胶囊和圆形是否保持全圆;
  • 是否为 corner-shape 提供了不支持时的回退;
  • 是否优先修改了设计 token。

圆角不是在每个组件上单独调一个数字,而是把“容器、间距、内层元素”的关系表达出来。圆心对齐之后,连续曲率才有意义。

圆角示例 Prompt

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Make the corner radii in this UI consistent, then switch them to continuous
corners. Work on the screen or components I name; ask me if I have not named
them. If the project has radius tokens, change those instead of hard-coding
values.

Inner radius = outer radius - padding (r = R - p)
Go from the outside in: dialog or card -> panels, inputs, buttons -> chips and
tags. A box p inside a container with radius R gets R - p, so both corners share
one center. Example: dialog 32, padding 16 -> panels and buttons 16; a chip 8
inside a 16 panel -> 8.
Boxes on the same level share one radius. Never go below 4.

Pills and circles stay fully round.
Keep every padding, gap and radius on a 4px grid.

Continuous corners:
Keep border-radius and add the curve as progressive enhancement:
@supports (corner-shape: superellipse(1.25)) {
:where(*) {
corner-shape: superellipse(1.25);
}
}
Set corner-shape: round on pills and circles.

Chrome and Edge 139+ render it; Safari and Firefox skip the block and show the
plain border-radius.
When done, list every radius you changed as "element: old -> new".

质感来自可解释的细节

递进式圆角解决的是秩序:每一层都知道自己与父级的关系。连续曲率解决的是观感:圆角不再像贴上去的几何图形,而是材料自然收束的边缘。

两者叠加之后,界面不会因为“多了几个像素”而显得精致,而是因为所有边界都遵循同一套可解释的关系。

站内搜索

没有找到内容!