1. Borders
  2. outline-offset

Borders

outline-offset

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

ClassStyles
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>

使用自定义值

Use the outline-offset-[<value>] syntax to set the outline offset based on a completely custom value:

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

For CSS variables, you can also use the outline-offset-(<custom-property>) syntax:

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

This is just a shorthand for outline-offset-[var(<custom-property>)] that adds the var() function for you automatically.

响应式设计

Prefix an outline-offset utility with a breakpoint variant like md: to only apply the utility at medium screen sizes and above:

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

Learn more about using variants in the variants documentation.

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