1. 背景
  2. 背景原点

背景

背景原点

用于控制元素的背景如何相对于边框、内边距和内容进行定位的工具类。

ClassStyles
bg-origin-border
background-origin: border-box;
bg-origin-padding
background-origin: padding-box;
bg-origin-content
background-origin: content-box;

示例

基本示例

使用 bg-origin-borderbg-origin-paddingbg-origin-content 工具类来控制元素背景的渲染位置:

bg-origin-border

bg-origin-padding

bg-origin-content

<div class="border-4 bg-[url(/img/mountains.jpg)] bg-origin-border p-3 ..."></div>
<div class="border-4 bg-[url(/img/mountains.jpg)] bg-origin-padding p-3 ..."></div>
<div class="border-4 bg-[url(/img/mountains.jpg)] bg-origin-content p-3 ..."></div>

响应式设计

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

<div class="bg-origin-border md:bg-origin-padding ...">
<!-- ... -->
</div>

Learn more about using variants in the variants documentation.