内嵌偏移 (Inset)

相对于元素的边缘对元素进行定位。

inset 属性(历史上称为 top、right、bottom、left)定义了定位元素的偏移量。其行为取决于 position 属性。

属性

inset 是 Taffy(以及 CSS 简写)中的辅助属性,用于设置:

属性描述
top距离顶部的距离。
bottom距离底部的距离。
left距离左侧的距离。
right距离右侧的距离。

行为

  • 对于 Position.Absolute:由直接父布局容器定位,通常相对于父 padding box 的边缘;Grid 中指定网格线时还可限定定位区域。
  • 对于 Position.Relative:偏移量相对于元素在流中的正常位置。

示例

Loading Preview…

后续步骤

© 2026 ByteLand Technology Limited