1. 边框
  2. outline-offset

边框

outline-offset

用于控制元素轮廓偏移的实用工具。

样式
outline-offset-<number>
outline-offset: <number>px;
-outline-offset-<number>
outline-offset: calc(<number>px * -1);
outline-offset-(<custom-property>)
outline-offset: var(<custom-property>);
outline-offset-[<value>]
outline-offset: <value>;

示例

基础示例

使用类似 outline-offset-2outline-offset-4 这样的实用工具来更改元素轮廓的偏移

outline-offset-0

outline-offset-2

outline-offset-4

<button class="outline-2 outline-offset-0 ...">Button A</button>
<button class="outline-2 outline-offset-2 ...">Button B</button>
<button class="outline-2 outline-offset-4 ...">Button C</button>

使用自定义值

使用 outline-offset-[<value>] 语法 来设置outline offset基于完全自定义的值

<div class="outline-offset-[2vw] ...">
<!-- ... -->
</div>

对于 CSS 变量,你也可以使用 outline-offset-(<custom-property>) 语法

<div class="outline-offset-(--my-outline-offset) ...">
<!-- ... -->
</div>

这只是 outline-offset-[var(<custom-property>)] 的简写形式,它会自动为你添加 var() 函数。

响应式设计

前缀 outline-offset 实用工具 添加类似 md: 这样的断点变体,以仅在中等 屏幕尺寸及以上应用该实用工具

<div class="outline md:outline-offset-2 ...">
<!-- ... -->
</div>

了解更多关于在变体文档中使用变体的信息。变体文档

版权所有 © 2025 Tailwind Labs Inc.·商标政策