1. 边框
  2. outline-offset

边框

outline-offset

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

样式
outline-offset-<number>
outline-offset: <number>px;
-outline-offset-<number>
outline-offset: calc(<number>px * -1);
outline-offset-(length:<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>] 语法 来设置轮廓偏移基于完全自定义的值

<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.·商标政策